]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-gui: shift tabstops to account for the first column of patch text
authorChris Idema <github_chris_idema@proton.me>
Thu, 29 Jan 2026 11:09:04 +0000 (11:09 +0000)
committerJohannes Sixt <j6t@kdbg.org>
Thu, 29 Jan 2026 21:34:53 +0000 (22:34 +0100)
When reviewing a change before staging, it is desirable to see text after
tabstops aligned the same way as in the text editor. However, since there
is always an additional character in column one in patch text ('+', '-',
or space), the alignment is broken if text before the first tab character
is just long enough to push the stop to the next tab position.

Commit a43c5f51a4b1 (git-gui: add configurable tab size to the diff view,
2012-02-12) added infrastructure that manipulates the tabstop positions
of the Tk text widget. However, it does so only when a 3-way diff is
shown and only so that it takes into account the one additional markup at
the beginning of lines. This only achieved that alignment does not get
worse for 3-way diffs compared to regular patch text, but left misaligned
text in regular patch text unmodified.

Use and modify this infrastructure to shift tabstops by one position for
regular patch text and two positions for 3-way diffs. Existing code
already resets the tabstops to an unshifted position when contents of
untracked files are displayed.

Signed-off-by: Chris Idema <github_chris_idema@proton.me>
[j6t: extend commit message]
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
lib/diff.tcl

index 442737ba4f260b16856d0cea8ae584d582d129b1..8be1a613fbe01f7c37cafded4d06f629f3c18ca4 100644 (file)
@@ -385,6 +385,8 @@ proc read_diff {fd conflict_size cont_info} {
                #
                if {[string match {@@@ *} $line]} {
                        set is_3way_diff 1
+                       apply_tab_size 2
+               } elseif {[string match {@@ *} $line]} {
                        apply_tab_size 1
                }