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
- 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".
- 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.
--ignore-space-at-eol only. Trailing whitespace drops out. Indent changes stay.
- Three controls, matching the three git flags. The diff bar gets crowded.
- 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
- Do you want an ignore-whitespace control on the diff at all?
- If yes, is one flag enough, and which git switch should it be:
-b, -w, or --ignore-space-at-eol?
- Should hunk stage stay disabled while the flag is on, since the displayed hunks are not the patch git would apply?
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, worktreeone\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 onDiffOptions.Options we considered
--ignore-all-space(-w). Indent and spaces inside the line both disappear.a bversusabalso disappears, which is more than "ignore the indent".--ignore-space-change(-b). A change in the amount of whitespace is hidden. Removing the space entirely (a bversusab) still shows.--ignore-space-at-eolonly. Trailing whitespace drops out. Indent changes stay.-w.While the flag is on, the hunks are not the patch
git applywould 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
-bor--ignore-space-at-eol.Questions for the maintainer
-b,-w, or--ignore-space-at-eol?