Subject: Re: [PATCH/RFC v3] diff.tcl: made alignment of tabs in git-gui diff consistent with gitk

From: Junio C Hamano <[email-masked]>
Date: Wed, 28 Jan 2026 16:02:13 -0800

"Chris Idema via GitGitGadget" <[email-masked]> writes:

> From: Chris Idema <[email-masked]>
>
> 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.

If git-gui has a feature to show file contents, not comparison of
the old and the new versions of a file as a diff, there won't be
plus or minus at the beginning.  The above paragraph of course is
mostly OK, but it would be more helpful to qualify it by talking
about "diff" somewhere.

    Because the diff view spends the leftmost column for plus sign
    for added line, minus sign for removed line, etc., a tab that
    would push the next character to multiple of 8 (or gui.tabsize)
    column may appear narrower by 1 column.

    Compensate for this by setting tabstops at 9th, 17th, 25th,
    ... columns (or 1+multiple of gui.tabsize) for showing a single
    parent diff, and shift by 2 columns for showing a two parent
    diff.

or something.

I noticed that gitk has code to deal with octopus merges (i.e., a
merge does not necessarily have two parents, but it is possible to
have more parents), but git-gui assumes that merges with two parents
are the only ones that are worth caring about.  Correcting for this
may be almost trivial, but I do not think it falls into the scope of
this topic.  But at least I think this topic should adjust existing
"apply_tab_size 1" used for two-parent merge combined diff to use 2.

>  git-gui/lib/diff.tcl | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
> index 442737ba4f..7da6e5ccae 100644
> --- a/git-gui/lib/diff.tcl
> +++ b/git-gui/lib/diff.tcl
> @@ -495,6 +495,7 @@ proc read_diff {fd conflict_size cont_info} {
>  			}
>  		}
>  		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}
>
> base-commit: 1faf5b085a171f9ba9a6d7a446e0de16acccb1dc