From: Chris Idema via GitGitGadget Date: Thu, 29 Jan 2026 11:09:04 GMT Subject: [PATCH v4] git-gui: shift tabstops to account for the first column of context diffs Message-ID: In-Reply-To: From: Chris Idema When reviewing a file before staging you want its content aligned using gui.tabsize. The prefixing of lines with +, - or space characters should not change this alignment. In gitk this is done correctly. In Git Gui not. Signed-off-by: Chris Idema --- git-gui: shift tabstops to account for the first column of context diffs cc: Johannes Sixt j6t@kdbg.org Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2179%2FChrisIdema%2Ffix-gitgui-diff-tab-alignment-v4 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2179/ChrisIdema/fix-gitgui-diff-tab-alignment-v4 Pull-Request: https://github.com/git/git/pull/2179 Range-diff vs v3: 1: 18d25b90c4 ! 1: 1c91363568 diff.tcl: made alignment of tabs in git-gui diff consistent with gitk @@ Metadata Author: Chris Idema ## Commit message ## - diff.tcl: made alignment of tabs in git-gui diff consistent with gitk + git-gui: shift tabstops to account for the first column of context diffs - Tab stop width was not properly rendered in TK regardless of - tab width setting. The + or minus character at start of line made - tabs align incorrectly. + When reviewing a file before staging you want its content aligned using + gui.tabsize. The prefixing of lines with +, - or space characters should + not change this alignment. In gitk this is done correctly. In Git Gui not. Signed-off-by: Chris Idema ## git-gui/lib/diff.tcl ## @@ git-gui/lib/diff.tcl: 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 } - set mark [$ui_diff index "end - 1 line linestart"] -+ apply_tab_size 1 - $ui_diff insert end $line $tags - if {[string index $line end] eq "\r"} { - $ui_diff tag add d_cr {end - 2c} + git-gui/lib/diff.tcl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl index 442737ba4f..8be1a613fb 100644 --- a/git-gui/lib/diff.tcl +++ b/git-gui/lib/diff.tcl @@ -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 } base-commit: 1faf5b085a171f9ba9a6d7a446e0de16acccb1dc -- gitgitgadget