git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4] git-gui: shift tabstops to account for the first column of context diffs

From
GitHub Chris Idema <github_chris_idema@proton.me>
Date
Mar 4, 2026, 13:32 UTC
Message-ID
<Hf23ZjoLMdkhr77C9rfhukpwi1zKpjyEwhMPfsqHbL4Cqruu8WRHHeFrX7mtPzxbmV3uyEgK5yXDBxUUVparcHo0f3PSipKEfTipswpYC68=@proton.me>
In-Reply-To
<191b6fe4-e273-4ecd-9b73-725c2dff4306@kdbg.org>
Any updates? I see it hasn't been merged yet.
Chris Idema

-------- Original Message -------- On Thursday, 01/29/26 at 22:36 Johannes Sixt <j6t@kdbg.org> wrote: Am 29.01.26 um 12:09 schrieb Chris Idema via GitGitGadget:

Show 8 quoted lines
> From: Chris Idema <github_chris_idema@proton.me>
>
> 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 <github_chris_idema@proton.me>
> ---
Show 17 quoted lines
>
>  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
>  		}
>

Just "else" without a condition would have been sufficient, but we can do it this way as well.

I've rewritten the commit message like so:
    git-gui: shift tabstops to account for the first column of patch text
    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>
In particular there was no bug; this is a new feature.

Thanks, -- Hannes

Previous: Johannes SixtNext: Johannes Sixt
Message 29 of 30 in “diff.tcl: fixed alignment of tabs in git-gui diff by using spaces”
  1. diff.tcl: fixed alignment of tabs in git-gui diff by using spacesChris Idema via GitGitGadget, Jan 26, 2026
  2. Johannes SixtJan 26, 2026
  3. GitHub Chris IdemaJan 26, 2026
  4. Johannes SixtJan 26, 2026
  5. GitHub Chris IdemaJan 26, 2026
  6. Johannes SixtJan 26, 2026
  7. GitHub Chris IdemaJan 26, 2026
  8. GitHub Chris IdemaJan 26, 2026
  9. 0/2 diff.tcl: Fixed alignment of tabs in git-gui diff by using spaces.Chris Idema via GitGitGadget, Jan 27, 2026
  10. 2/2 diff.tcl: call "apply_tab_size 1" to fix alignment instead of spaces.Chris Idema via GitGitGadget, Jan 27, 2026
  11. Junio C HamanoJan 27, 2026
  12. Junio C HamanoJan 27, 2026
  13. GitHub Chris IdemaJan 28, 2026
  14. Johannes SixtJan 28, 2026
  15. GitHub Chris IdemaJan 28, 2026
  16. Johannes SixtJan 28, 2026
  17. Junio C HamanoJan 28, 2026
  18. Junio C HamanoJan 29, 2026
  19. GitHub Chris IdemaJan 29, 2026
  20. Johannes SixtJan 29, 2026
  21. Junio C HamanoJan 29, 2026
  22. 1/2 diff.tcl: fixed alignment of tabs in git-gui diff by using spacesChris Idema via GitGitGadget, Jan 27, 2026
  23. diff.tcl: made alignment of tabs in git-gui diff consistent with gitkChris Idema via GitGitGadget, Jan 28, 2026
  24. Johannes SixtJan 28, 2026
  25. GitHub Chris IdemaJan 28, 2026
  26. Junio C HamanoJan 29, 2026
  27. git-gui: shift tabstops to account for the first column of context diffsChris Idema via GitGitGadget, Jan 29, 2026
  28. Johannes SixtJan 29, 2026
  29. GitHub Chris IdemaMar 4, 2026
  30. Johannes SixtMar 4, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.