Skip to content

Should the diff view grow a git-style ignore-whitespace control? #38

Description

@noyobo

The problem we hit

A file whose only change is indentation still paints a full add/del pair. There is no control to hide it.

macOS, WKWebView, app 0.16.0. Fixture: committed one\n two\nthree\n, worktree one\ntwo\nthree\n. The diff reports 1 addition and 1 deletion. This is not the unwrapped-minified-line jank, and not a missing font. The lines are real content that differs only by spaces.

git already has three switches: --ignore-space-change (-b), --ignore-all-space (-w), and --ignore-space-at-eol. libgit2 exposes the same three on DiffOptions.

Options we considered

  1. One toggle mapped to --ignore-all-space (-w). Indent and spaces inside the line both disappear. a b versus ab also disappears, which is more than "ignore the indent".
  2. One toggle mapped to --ignore-space-change (-b). A change in the amount of whitespace is hidden. Removing the space entirely (a b versus ab) still shows.
  3. --ignore-space-at-eol only. Trailing whitespace drops out. Indent changes stay.
  4. Three controls, matching the three git flags. The diff bar gets crowded.
  5. Leave it out. The user runs git in a terminal when they want -w.

While the flag is on, the hunks are not the patch git apply would stage. We turn hunk stage off in that mode rather than stage the filtered text.

What we verified works

Option 1, as a boolean on the file, commit, and range diff calls, passed through to libgit2 DiffOptions::ignore_whitespace.

On the fixture above, the same file diff with the flag set reports 0 additions and 0 deletions. With the flag clear, the indent change is still a non-zero delta. A real token change is unaffected. We did not implement -b or --ignore-space-at-eol.

Questions for the maintainer

  1. Do you want an ignore-whitespace control on the diff at all?
  2. If yes, is one flag enough, and which git switch should it be: -b, -w, or --ignore-space-at-eol?
  3. Should hunk stage stay disabled while the flag is on, since the displayed hunks are not the patch git would apply?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions