public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Chris Idema via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,  Chris Idema <github_chris_idema@proton.me>
Subject: Re: [PATCH/RFC v2 2/2] diff.tcl: call "apply_tab_size 1" to fix alignment instead of spaces.
Date: Tue, 27 Jan 2026 14:19:16 -0800	[thread overview]
Message-ID: <xmqqsebqem1n.fsf@gitster.g> (raw)
In-Reply-To: <e11aa6d811dcf868fd0f91b74cdceb8bc3f4229e.1769545996.git.gitgitgadget@gmail.com> (Chris Idema via GitGitGadget's message of "Tue, 27 Jan 2026 20:33:16 +0000")

"Chris Idema via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Chris Idema <github_chris_idema@proton.me>
>
> Signed-off-by: Chris Idema <github_chris_idema@proton.me>
> ---
>  git-gui/lib/diff.tcl | 24 +-----------------------
>  1 file changed, 1 insertion(+), 23 deletions(-)
>
> diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
> index 2e13f8c776..0f0951cc57 100644
> --- a/git-gui/lib/diff.tcl
> +++ b/git-gui/lib/diff.tcl
> @@ -12,27 +12,6 @@ proc apply_tab_size {{firsttab {}}} {
>  	}
>  }
>  
> -proc expand_tabs {line {startcol -1}} {
> -	# startcol set to -1, because in preview the lines start with a '+', '-', or ' '
> -	global repo_config
> -
> -	set col $startcol
> -	set out ""
> -
> -	foreach char [split $line ""] {
> -		if {$char eq "\t"} {
> -			set spaces [expr {$repo_config(gui.tabsize) - ($col % $repo_config(gui.tabsize))}]
> -			append out [string repeat " " $spaces]
> -			incr col $spaces
> -		} else {
> -			append out $char
> -			incr col
> -		}
> -	}
> -
> -	return $out
> -}
> -
>  proc clear_diff {} {
>  	global ui_diff current_diff_path current_diff_header
>  	global ui_index ui_workdir
> @@ -516,9 +495,8 @@ proc read_diff {fd conflict_size cont_info} {
>  			}
>  		}
>  		set mark [$ui_diff index "end - 1 line linestart"]
> -		set line [expand_tabs $line]
> +		apply_tab_size 1
>  		$ui_diff insert end "$line" $tags
> -

Why does this series first add proc expand_tabs, only to remove its
use in this second step?  Shouldn't these two patches be squashed
into one, and explain why we want to use "apply_tab_size 1" here?

It smells fishy to do "apply_tab_size 1" here in "proc clear_diff".

It is called from "proc show_diff" but the latter, after it calls
clear_diff, calls "apply_tab_size 0".  Doesn't that defeat the
effect of this new call added to "proc clear_diff"?

By the way, this has nothing to do with your change, but the only
existing use of "apply_tab_size 1" is also somewhat curious.  When
"proc read_diff" detects that a patch hunk header has three (not the
usual two) at-signs, it calls "apply_tab_size 1", presumably to
adjust to the fact that combined diff has two leading columns used
to signal added/removed/context lines, instead of one.

Apparently the author of the original code thought that it is a good
idea for such a payload if first tab moves 1 column, and second and
subsequent tabs taking gui.tabsize after that tabstop.  A line in
combined diff uses two leading columns for line prefix.  Isn't it
curious that these two patches under discussion claim that the same
exact setting of "apply_tab_size 1" is appropriate for _anything_
that is shown in the $ui_diff widget prepared with "proc
clear_diff"?

Presumably most of the time, the output format would use just a
single leading column for line prefix added (+), removed (-), or
context ( ).

Both cannot be correct at the same time, can they?

So, either the original author is wrong and the current code is
broken with or without your change when it shows a combined diff, or
these patches is wrong and there is off-by-one bug somwhere.

Puzzled and curious ...


  reply	other threads:[~2026-01-27 22:19 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-26 10:45 [PATCH] diff.tcl: fixed alignment of tabs in git-gui diff by using spaces Chris Idema via GitGitGadget
2026-01-26 12:15 ` Johannes Sixt
2026-01-26 13:32   ` GitHub Chris Idema
2026-01-26 13:59     ` Johannes Sixt
2026-01-26 14:43       ` GitHub Chris Idema
2026-01-26 14:52         ` Johannes Sixt
2026-01-26 15:21           ` GitHub Chris Idema
2026-01-26 15:32           ` GitHub Chris Idema
2026-01-27 20:33 ` [PATCH/RFC v2 0/2] diff.tcl: Fixed " Chris Idema via GitGitGadget
2026-01-27 20:33   ` [PATCH/RFC v2 1/2] diff.tcl: fixed " Chris Idema via GitGitGadget
2026-01-27 20:33   ` [PATCH/RFC v2 2/2] diff.tcl: call "apply_tab_size 1" to fix alignment instead of spaces Chris Idema via GitGitGadget
2026-01-27 22:19     ` Junio C Hamano [this message]
2026-01-27 23:26       ` Junio C Hamano
2026-01-28  9:07         ` GitHub Chris Idema
2026-01-28 13:40         ` Johannes Sixt
2026-01-28 14:02           ` GitHub Chris Idema
2026-01-28 15:59             ` Johannes Sixt
2026-01-28 23:42               ` Junio C Hamano
2026-01-29  0:06           ` Junio C Hamano
2026-01-29  8:31             ` GitHub Chris Idema
2026-01-29 10:04               ` Johannes Sixt
2026-01-29 15:17                 ` Junio C Hamano
2026-01-28 10:20   ` [PATCH/RFC v3] diff.tcl: made alignment of tabs in git-gui diff consistent with gitk Chris Idema via GitGitGadget
2026-01-28 17:02     ` Johannes Sixt
2026-01-28 19:02       ` GitHub Chris Idema
2026-01-29  0:02     ` Junio C Hamano
2026-01-29 11:09     ` [PATCH v4] git-gui: shift tabstops to account for the first column of context diffs Chris Idema via GitGitGadget
2026-01-29 21:36       ` Johannes Sixt
2026-03-04 13:32         ` GitHub Chris Idema
2026-03-04 19:22           ` Johannes Sixt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqsebqem1n.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=github_chris_idema@proton.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox