{"thread":{"id":"64867","subject":"[PATCH] diff.tcl: fixed alignment of tabs in git-gui diff by using spaces","startedAt":"2026-01-26T10:45:04Z","lastAt":"2026-03-04T19:22:19Z","messageCount":30,"participants":["Chris Idema via GitGitGadget","Johannes Sixt","GitHub Chris Idema","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"534655","messageId":"pull.2179.git.git.1769424301394.gitgitgadget@gmail.com","threadId":"64867","inReplyTo":null,"subject":"[PATCH] diff.tcl: fixed alignment of tabs in git-gui diff by using spaces","fromName":"Chris Idema via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-01-26T10:45:01Z","receivedAt":"2026-01-26T10:45:04Z","isPatch":true,"sender":{"key":"name:Chris Idema","avatar":null},"body":"From: Chris Idema <github_chris_idema@proton.me>\n\nTabs were not properly rendered in TK regardless of tab width settings.\nConverting tab alignment to spaces before rendering in TK fixes this.\nDoes not fix alignment issues in gitk.\n\nSigned-off-by: Chris Idema <github_chris_idema@proton.me>\n---\n    diff.tcl: Fixed alignment of tabs in git-gui diff by using spaces.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2179%2FChrisIdema%2Ffix-gitgui-diff-tab-alignment-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2179/ChrisIdema/fix-gitgui-diff-tab-alignment-v1\nPull-Request: https://github.com/git/git/pull/2179\n\n git-gui/lib/diff.tcl | 25 ++++++++++++++++++++++++-\n 1 file changed, 24 insertions(+), 1 deletion(-)\n\ndiff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\nindex 442737ba4f..2e13f8c776 100644\n--- a/git-gui/lib/diff.tcl\n+++ b/git-gui/lib/diff.tcl\n@@ -12,6 +12,27 @@ proc apply_tab_size {{firsttab {}}} {\n \t}\n }\n \n+proc expand_tabs {line {startcol -1}} {\n+\t# startcol set to -1, because in preview the lines start with a '+', '-', or ' '\n+\tglobal repo_config\n+\n+\tset col $startcol\n+\tset out \"\"\n+\n+\tforeach char [split $line \"\"] {\n+\t\tif {$char eq \"\\t\"} {\n+\t\t\tset spaces [expr {$repo_config(gui.tabsize) - ($col % $repo_config(gui.tabsize))}]\n+\t\t\tappend out [string repeat \" \" $spaces]\n+\t\t\tincr col $spaces\n+\t\t} else {\n+\t\t\tappend out $char\n+\t\t\tincr col\n+\t\t}\n+\t}\n+\n+\treturn $out\n+}\n+\n proc clear_diff {} {\n \tglobal ui_diff current_diff_path current_diff_header\n \tglobal ui_index ui_workdir\n@@ -495,7 +516,9 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t\t}\n \t\t}\n \t\tset mark [$ui_diff index \"end - 1 line linestart\"]\n-\t\t$ui_diff insert end $line $tags\n+\t\tset line [expand_tabs $line]\n+\t\t$ui_diff insert end \"$line\" $tags\n+\n \t\tif {[string index $line end] eq \"\\r\"} {\n \t\t\t$ui_diff tag add d_cr {end - 2c}\n \t\t}\n\nbase-commit: 1faf5b085a171f9ba9a6d7a446e0de16acccb1dc\n-- \ngitgitgadget\n"},{"id":"534659","messageId":"01d0faaf-99fb-42a4-befd-bb7f359809bc@kdbg.org","threadId":"64867","inReplyTo":"pull.2179.git.git.1769424301394.gitgitgadget@gmail.com","subject":"Re: [PATCH] diff.tcl: fixed alignment of tabs in git-gui diff by using spaces","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2026-01-26T12:15:26Z","receivedAt":"2026-01-26T12:15:35Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 26.01.26 um 11:45 schrieb Chris Idema via GitGitGadget:\n> From: Chris Idema <github_chris_idema@proton.me>\n> \n> Tabs were not properly rendered in TK regardless of tab width settings.\n\nSorry, I cannot reproduce what I read into this sentence. When I change\nthe \"Tab spacing\" option in the Options dialog, the display changes to\nthe specified tab width. I'm using Tcl/Tk 8.6.\n\n> Converting tab alignment to spaces before rendering in TK fixes this.\n\nDo \"Stage Line/Hunk for Commit\" still work after this conversion?\n\n-- Hannes\n\n"},{"id":"534665","messageId":"Lj9kojJwK1ZAtvE5nj6rTq5EXf1-QhsRlmBDM9YntbYeWb3J07mlbM-njNco2XT1pSPXsNVbo9Uc5kJOHihb11odjthYN4YtuhVdNwxSIqk=@proton.me","threadId":"64867","inReplyTo":"01d0faaf-99fb-42a4-befd-bb7f359809bc@kdbg.org","subject":"Re: [PATCH] diff.tcl: fixed alignment of tabs in git-gui diff by using spaces","fromName":"GitHub Chris Idema","fromEmail":"github_chris_idema@proton.me","sentAt":"2026-01-26T13:32:28Z","receivedAt":"2026-01-26T13:32:42Z","isPatch":true,"sender":{"key":"github_chris_idema@proton.me","avatar":"https://avatars.githubusercontent.com/u/48433711?v=4"},"body":"> Sorry, I cannot reproduce what I read into this sentence. When I change\nthe \"Tab spacing\" option in the Options dialog, the display changes to\nthe specified tab width. I'm using Tcl/Tk 8.6.\n\nI use git for Windows version \"2.52.0.windows.1\" on Windows 11.\n\nHere is how you can reproduce the problem:\nmkdir test_tabs\ncd test_tabs\ngit init\necho \"\" > test.c\ngit add .\ngit commit -m \"initial commit\"\necho -e \"int test1\\t= 5;\\nint test11\\t= 6;\\nint test111\\t= 6;\\n\" > test.c\ngit gui\n\n> Do \"Stage Line/Hunk for Commit\" still work after this conversion?\nI'm sorry but I don't know what this means.\n\n-- Chris\n\n-------- Original Message --------\nOn Monday, 01/26/26 at 13:15 Johannes Sixt <j6t@kdbg.org> wrote:\nAm 26.01.26 um 11:45 schrieb Chris Idema via GitGitGadget:\n> From: Chris Idema <github_chris_idema@proton.me>\n>\n> Tabs were not properly rendered in TK regardless of tab width settings.\n\nSorry, I cannot reproduce what I read into this sentence. When I change\nthe \"Tab spacing\" option in the Options dialog, the display changes to\nthe specified tab width. I'm using Tcl/Tk 8.6.\n\n> Converting tab alignment to spaces before rendering in TK fixes this.\n\nDo \"Stage Line/Hunk for Commit\" still work after this conversion?\n\n-- Hannes\n\n\n"},{"id":"534666","messageId":"07014d88-67ed-498a-8cc1-423c77972fd7@kdbg.org","threadId":"64867","inReplyTo":"Lj9kojJwK1ZAtvE5nj6rTq5EXf1-QhsRlmBDM9YntbYeWb3J07mlbM-njNco2XT1pSPXsNVbo9Uc5kJOHihb11odjthYN4YtuhVdNwxSIqk=@proton.me","subject":"Re: [PATCH] diff.tcl: fixed alignment of tabs in git-gui diff by using spaces","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2026-01-26T13:59:21Z","receivedAt":"2026-01-26T13:59:30Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 26.01.26 um 14:32 schrieb GitHub Chris Idema:\n> Here is how you can reproduce the problem:\n> mkdir test_tabs\n> cd test_tabs\n> git init\n> echo \"\" > test.c\n> git add .\n> git commit -m \"initial commit\"\n> echo -e \"int test1\\t= 5;\\nint test11\\t= 6;\\nint test111\\t= 6;\\n\" > test.c\n> git gui\n\nSo, you mean that if the tab width is set to 4, then the tab stops are\nnot aligned anymore?\n\n>> Do \"Stage Line/Hunk for Commit\" still work after this conversion?\n> I'm sorry but I don't know what this means.\n\nThese are commands in the context menu of the diff panel. They extract\nthe text from the widget and massage it into a patch. My suspicion is\nthat the patch text does not match the actual file contents, and so the\ncommands fail.\n\n-- Hannes\n\n"},{"id":"534668","messageId":"sYbEiapPid30QZ89paQ6hF_v4BjKnAqUTOt_ImBEfFYBlMVU9uoGwZbKqSkk7aZVxGPrqVXbb58Ogppnw0gQEbH1gwRfBmx3HC2AECWjGkY=@proton.me","threadId":"64867","inReplyTo":"07014d88-67ed-498a-8cc1-423c77972fd7@kdbg.org","subject":"Re: [PATCH] diff.tcl: fixed alignment of tabs in git-gui diff by using spaces","fromName":"GitHub Chris Idema","fromEmail":"github_chris_idema@proton.me","sentAt":"2026-01-26T14:43:36Z","receivedAt":"2026-01-26T14:43:43Z","isPatch":true,"sender":{"key":"github_chris_idema@proton.me","avatar":"https://avatars.githubusercontent.com/u/48433711?v=4"},"body":"> So, you mean that if the tab width is set to 4, then the tab stops are not aligned anymore?\n\nIndeed. It's probably due to the + character shifting everything by 1 character.\n\n> My suspicion is that the patch text does not match the actual file contents, and so the commands fail.\n\nIf you select and copy the text from the window with you mouse it won't match the patch. I didn't know people used it that way. I use it as a way to review my changes before staging.\nI don't know if there is a way to make it that when you copy it will copy the original text and no the modified text.\nIf not then we should come up with a better way to align stops.\n\n-- Chris\n\n-------- Original Message --------\nOn Monday, 01/26/26 at 14:59 Johannes Sixt <j6t@kdbg.org> wrote:\nAm 26.01.26 um 14:32 schrieb GitHub Chris Idema:\n> Here is how you can reproduce the problem:\n> mkdir test_tabs\n> cd test_tabs\n> git init\n> echo \"\" > test.c\n> git add .\n> git commit -m \"initial commit\"\n> echo -e \"int test1\\t= 5;\\nint test11\\t= 6;\\nint test111\\t= 6;\\n\" > test.c\n> git gui\n\nSo, you mean that if the tab width is set to 4, then the tab stops are\nnot aligned anymore?\n\n>> Do \"Stage Line/Hunk for Commit\" still work after this conversion?\n> I'm sorry but I don't know what this means.\n\nThese are commands in the context menu of the diff panel. They extract\nthe text from the widget and massage it into a patch. My suspicion is\nthat the patch text does not match the actual file contents, and so the\ncommands fail.\n\n-- Hannes\n\n\n"},{"id":"534669","messageId":"5ab10a31-8ee5-48f9-a5fd-63c6d7f4adcf@kdbg.org","threadId":"64867","inReplyTo":"sYbEiapPid30QZ89paQ6hF_v4BjKnAqUTOt_ImBEfFYBlMVU9uoGwZbKqSkk7aZVxGPrqVXbb58Ogppnw0gQEbH1gwRfBmx3HC2AECWjGkY=@proton.me","subject":"Re: [PATCH] diff.tcl: fixed alignment of tabs in git-gui diff by using spaces","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2026-01-26T14:52:38Z","receivedAt":"2026-01-26T14:52:41Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 26.01.26 um 15:43 schrieb GitHub Chris Idema:\n>> So, you mean that if the tab width is set to 4, then the tab stops\n>> are not aligned anymore?\n> \n> Indeed. It's probably due to the + character shifting everything by 1 character.\n\nBTW, this isn't a problem with a particular tab width. It happens with\nthe default width 8 as well.\n\n>> My suspicion is that the patch text does not match the actual file\n>> contents, and so the commands fail.\n> \n> If you select and copy the text from the window with you mouse it\n> won't match the patch. I didn't know people used it that way. I use\n> it as a way to review my changes before staging.\n\nI don't mean copy-and-paste. I mean the context menu commands. They stop\nworking (I suspect). This would be a show-stopper.\n\n> I don't know if there is a way to make it that when you copy it will\n> copy the original text and no the modified text. If not then we\n> should come up with a better way to align stops.\n\nI am not particularly fond of such a change. Years and years of reading\npatch text has trained my brain to expect such misalignment to the\nextent that even the absence of misalignment can sometimes indicate a\nwhitespace error.\n\n-- Hannes\n\n"},{"id":"534670","messageId":"cN1fnsEmJFcm0Tn-hnMbo4tx4U4_SXBxO1s7j0NjOOv2Fn-sH0IsQTX2QqxD7g1bt_7aOSjXNEIBoLAMJT25UZLwr-Uzh9jFC_vBZ9QlLy8=@proton.me","threadId":"64867","inReplyTo":"5ab10a31-8ee5-48f9-a5fd-63c6d7f4adcf@kdbg.org","subject":"Re: [PATCH] diff.tcl: fixed alignment of tabs in git-gui diff by using spaces","fromName":"GitHub Chris Idema","fromEmail":"github_chris_idema@proton.me","sentAt":"2026-01-26T15:21:06Z","receivedAt":"2026-01-26T15:21:14Z","isPatch":true,"sender":{"key":"github_chris_idema@proton.me","avatar":"https://avatars.githubusercontent.com/u/48433711?v=4"},"body":"> I am not particularly fond of such a change. Years and years of reading\npatch text has trained my brain to expect such misalignment to the\nextent that even the absence of misalignment can sometimes indicate a\nwhitespace error.\n\nThe problem is not just incorrect alignment. It's also inconsistency. In gitk the alignment is correct. In the git gui window it's not.  The best solution would be to make the git gui window behave like gitk. I thought my change only affected the way it was displayed. I'm going to see if there is a better way.\n\n-- Chris\n\n-------- Original Message --------\nOn Monday, 01/26/26 at 15:52 Johannes Sixt <j6t@kdbg.org> wrote:\nAm 26.01.26 um 15:43 schrieb GitHub Chris Idema:\n>> So, you mean that if the tab width is set to 4, then the tab stops\n>> are not aligned anymore?\n>\n> Indeed. It's probably due to the + character shifting everything by 1 character.\n\nBTW, this isn't a problem with a particular tab width. It happens with\nthe default width 8 as well.\n\n>> My suspicion is that the patch text does not match the actual file\n>> contents, and so the commands fail.\n>\n> If you select and copy the text from the window with you mouse it\n> won't match the patch. I didn't know people used it that way. I use\n> it as a way to review my changes before staging.\n\nI don't mean copy-and-paste. I mean the context menu commands. They stop\nworking (I suspect). This would be a show-stopper.\n\n> I don't know if there is a way to make it that when you copy it will\n> copy the original text and no the modified text. If not then we\n> should come up with a better way to align stops.\n\nI am not particularly fond of such a change. Years and years of reading\npatch text has trained my brain to expect such misalignment to the\nextent that even the absence of misalignment can sometimes indicate a\nwhitespace error.\n\n-- Hannes\n\n\n"},{"id":"534671","messageId":"fOsJj5fE2gNmoO568x1CpXIsgppqEoG3Olvz7Ze7SMjaaephgqUdNARafGPNwDSAFSxRFNMMlRvDrD_dOW7ARFLxiJpgXd84ezzOwnKZBdM=@proton.me","threadId":"64867","inReplyTo":"5ab10a31-8ee5-48f9-a5fd-63c6d7f4adcf@kdbg.org","subject":"Re: [PATCH] diff.tcl: fixed alignment of tabs in git-gui diff by using spaces","fromName":"GitHub Chris Idema","fromEmail":"github_chris_idema@proton.me","sentAt":"2026-01-26T15:32:41Z","receivedAt":"2026-01-26T15:32:45Z","isPatch":true,"sender":{"key":"github_chris_idema@proton.me","avatar":"https://avatars.githubusercontent.com/u/48433711?v=4"},"body":"It appears inserting \"apply_tab_size 1\" fixes the issue. But I don't know if I'm inserting it in the right place.\n\n-- Chris\n\n\n"},{"id":"534724","messageId":"pull.2179.v2.git.git.1769545996.gitgitgadget@gmail.com","threadId":"64867","inReplyTo":"pull.2179.git.git.1769424301394.gitgitgadget@gmail.com","subject":"[PATCH/RFC v2 0/2] diff.tcl: Fixed alignment of tabs in git-gui diff by using spaces.","fromName":"Chris Idema via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-01-27T20:33:14Z","receivedAt":"2026-01-27T20:33:18Z","isPatch":true,"sender":{"key":"name:Chris Idema","avatar":null},"body":"cc: Johannes Sixt j6t@kdbg.org\n\nChris Idema (2):\n  diff.tcl: fixed alignment of tabs in git-gui diff by using spaces\n  diff.tcl: call \"apply_tab_size 1\" to fix alignment instead of spaces.\n\n git-gui/lib/diff.tcl | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\n\nbase-commit: 1faf5b085a171f9ba9a6d7a446e0de16acccb1dc\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2179%2FChrisIdema%2Ffix-gitgui-diff-tab-alignment-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2179/ChrisIdema/fix-gitgui-diff-tab-alignment-v2\nPull-Request: https://github.com/git/git/pull/2179\n\nRange-diff vs v1:\n\n 1:  f2a09c15eb = 1:  f2a09c15eb diff.tcl: fixed alignment of tabs in git-gui diff by using spaces\n -:  ---------- > 2:  e11aa6d811 diff.tcl: call \"apply_tab_size 1\" to fix alignment instead of spaces.\n\n-- \ngitgitgadget\n"},{"id":"534725","messageId":"e11aa6d811dcf868fd0f91b74cdceb8bc3f4229e.1769545996.git.gitgitgadget@gmail.com","threadId":"64867","inReplyTo":"pull.2179.v2.git.git.1769545996.gitgitgadget@gmail.com","subject":"[PATCH/RFC v2 2/2] diff.tcl: call \"apply_tab_size 1\" to fix alignment instead of spaces.","fromName":"Chris Idema via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-01-27T20:33:16Z","receivedAt":"2026-01-27T20:33:20Z","isPatch":true,"sender":{"key":"name:Chris Idema","avatar":null},"body":"From: Chris Idema <github_chris_idema@proton.me>\n\nSigned-off-by: Chris Idema <github_chris_idema@proton.me>\n---\n git-gui/lib/diff.tcl | 24 +-----------------------\n 1 file changed, 1 insertion(+), 23 deletions(-)\n\ndiff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\nindex 2e13f8c776..0f0951cc57 100644\n--- a/git-gui/lib/diff.tcl\n+++ b/git-gui/lib/diff.tcl\n@@ -12,27 +12,6 @@ proc apply_tab_size {{firsttab {}}} {\n \t}\n }\n \n-proc expand_tabs {line {startcol -1}} {\n-\t# startcol set to -1, because in preview the lines start with a '+', '-', or ' '\n-\tglobal repo_config\n-\n-\tset col $startcol\n-\tset out \"\"\n-\n-\tforeach char [split $line \"\"] {\n-\t\tif {$char eq \"\\t\"} {\n-\t\t\tset spaces [expr {$repo_config(gui.tabsize) - ($col % $repo_config(gui.tabsize))}]\n-\t\t\tappend out [string repeat \" \" $spaces]\n-\t\t\tincr col $spaces\n-\t\t} else {\n-\t\t\tappend out $char\n-\t\t\tincr col\n-\t\t}\n-\t}\n-\n-\treturn $out\n-}\n-\n proc clear_diff {} {\n \tglobal ui_diff current_diff_path current_diff_header\n \tglobal ui_index ui_workdir\n@@ -516,9 +495,8 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t\t}\n \t\t}\n \t\tset mark [$ui_diff index \"end - 1 line linestart\"]\n-\t\tset line [expand_tabs $line]\n+\t\tapply_tab_size 1\n \t\t$ui_diff insert end \"$line\" $tags\n-\n \t\tif {[string index $line end] eq \"\\r\"} {\n \t\t\t$ui_diff tag add d_cr {end - 2c}\n \t\t}\n-- \ngitgitgadget\n"},{"id":"534726","messageId":"f2a09c15eb600c4de8ca2e25596f02ad9d1c30f7.1769545996.git.gitgitgadget@gmail.com","threadId":"64867","inReplyTo":"pull.2179.v2.git.git.1769545996.gitgitgadget@gmail.com","subject":"[PATCH/RFC v2 1/2] diff.tcl: fixed alignment of tabs in git-gui diff by using spaces","fromName":"Chris Idema via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-01-27T20:33:15Z","receivedAt":"2026-01-27T20:33:21Z","isPatch":true,"sender":{"key":"name:Chris Idema","avatar":null},"body":"From: Chris Idema <github_chris_idema@proton.me>\n\nTabs were not properly rendered in TK regardless of tab width settings.\nConverting tab alignment to spaces before rendering in TK fixes this.\nDoes not fix alignment issues in gitk.\n\nSigned-off-by: Chris Idema <github_chris_idema@proton.me>\n---\n git-gui/lib/diff.tcl | 25 ++++++++++++++++++++++++-\n 1 file changed, 24 insertions(+), 1 deletion(-)\n\ndiff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\nindex 442737ba4f..2e13f8c776 100644\n--- a/git-gui/lib/diff.tcl\n+++ b/git-gui/lib/diff.tcl\n@@ -12,6 +12,27 @@ proc apply_tab_size {{firsttab {}}} {\n \t}\n }\n \n+proc expand_tabs {line {startcol -1}} {\n+\t# startcol set to -1, because in preview the lines start with a '+', '-', or ' '\n+\tglobal repo_config\n+\n+\tset col $startcol\n+\tset out \"\"\n+\n+\tforeach char [split $line \"\"] {\n+\t\tif {$char eq \"\\t\"} {\n+\t\t\tset spaces [expr {$repo_config(gui.tabsize) - ($col % $repo_config(gui.tabsize))}]\n+\t\t\tappend out [string repeat \" \" $spaces]\n+\t\t\tincr col $spaces\n+\t\t} else {\n+\t\t\tappend out $char\n+\t\t\tincr col\n+\t\t}\n+\t}\n+\n+\treturn $out\n+}\n+\n proc clear_diff {} {\n \tglobal ui_diff current_diff_path current_diff_header\n \tglobal ui_index ui_workdir\n@@ -495,7 +516,9 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t\t}\n \t\t}\n \t\tset mark [$ui_diff index \"end - 1 line linestart\"]\n-\t\t$ui_diff insert end $line $tags\n+\t\tset line [expand_tabs $line]\n+\t\t$ui_diff insert end \"$line\" $tags\n+\n \t\tif {[string index $line end] eq \"\\r\"} {\n \t\t\t$ui_diff tag add d_cr {end - 2c}\n \t\t}\n-- \ngitgitgadget\n\n"},{"id":"534732","messageId":"xmqqsebqem1n.fsf@gitster.g","threadId":"64867","inReplyTo":"e11aa6d811dcf868fd0f91b74cdceb8bc3f4229e.1769545996.git.gitgitgadget@gmail.com","subject":"Re: [PATCH/RFC v2 2/2] diff.tcl: call \"apply_tab_size 1\" to fix alignment instead of spaces.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-01-27T22:19:16Z","receivedAt":"2026-01-27T22:19:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Chris Idema via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Chris Idema <github_chris_idema@proton.me>\n>\n> Signed-off-by: Chris Idema <github_chris_idema@proton.me>\n> ---\n>  git-gui/lib/diff.tcl | 24 +-----------------------\n>  1 file changed, 1 insertion(+), 23 deletions(-)\n>\n> diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\n> index 2e13f8c776..0f0951cc57 100644\n> --- a/git-gui/lib/diff.tcl\n> +++ b/git-gui/lib/diff.tcl\n> @@ -12,27 +12,6 @@ proc apply_tab_size {{firsttab {}}} {\n>  \t}\n>  }\n>  \n> -proc expand_tabs {line {startcol -1}} {\n> -\t# startcol set to -1, because in preview the lines start with a '+', '-', or ' '\n> -\tglobal repo_config\n> -\n> -\tset col $startcol\n> -\tset out \"\"\n> -\n> -\tforeach char [split $line \"\"] {\n> -\t\tif {$char eq \"\\t\"} {\n> -\t\t\tset spaces [expr {$repo_config(gui.tabsize) - ($col % $repo_config(gui.tabsize))}]\n> -\t\t\tappend out [string repeat \" \" $spaces]\n> -\t\t\tincr col $spaces\n> -\t\t} else {\n> -\t\t\tappend out $char\n> -\t\t\tincr col\n> -\t\t}\n> -\t}\n> -\n> -\treturn $out\n> -}\n> -\n>  proc clear_diff {} {\n>  \tglobal ui_diff current_diff_path current_diff_header\n>  \tglobal ui_index ui_workdir\n> @@ -516,9 +495,8 @@ proc read_diff {fd conflict_size cont_info} {\n>  \t\t\t}\n>  \t\t}\n>  \t\tset mark [$ui_diff index \"end - 1 line linestart\"]\n> -\t\tset line [expand_tabs $line]\n> +\t\tapply_tab_size 1\n>  \t\t$ui_diff insert end \"$line\" $tags\n> -\n\nWhy does this series first add proc expand_tabs, only to remove its\nuse in this second step?  Shouldn't these two patches be squashed\ninto one, and explain why we want to use \"apply_tab_size 1\" here?\n\nIt smells fishy to do \"apply_tab_size 1\" here in \"proc clear_diff\".\n\nIt is called from \"proc show_diff\" but the latter, after it calls\nclear_diff, calls \"apply_tab_size 0\".  Doesn't that defeat the\neffect of this new call added to \"proc clear_diff\"?\n\nBy the way, this has nothing to do with your change, but the only\nexisting use of \"apply_tab_size 1\" is also somewhat curious.  When\n\"proc read_diff\" detects that a patch hunk header has three (not the\nusual two) at-signs, it calls \"apply_tab_size 1\", presumably to\nadjust to the fact that combined diff has two leading columns used\nto signal added/removed/context lines, instead of one.\n\nApparently the author of the original code thought that it is a good\nidea for such a payload if first tab moves 1 column, and second and\nsubsequent tabs taking gui.tabsize after that tabstop.  A line in\ncombined diff uses two leading columns for line prefix.  Isn't it\ncurious that these two patches under discussion claim that the same\nexact setting of \"apply_tab_size 1\" is appropriate for _anything_\nthat is shown in the $ui_diff widget prepared with \"proc\nclear_diff\"?\n\nPresumably most of the time, the output format would use just a\nsingle leading column for line prefix added (+), removed (-), or\ncontext ( ).\n\nBoth cannot be correct at the same time, can they?\n\nSo, either the original author is wrong and the current code is\nbroken with or without your change when it shows a combined diff, or\nthese patches is wrong and there is off-by-one bug somwhere.\n\nPuzzled and curious ...\n\n"},{"id":"534736","messageId":"xmqqfr7qeixq.fsf@gitster.g","threadId":"64867","inReplyTo":"xmqqsebqem1n.fsf@gitster.g","subject":"Re: [PATCH/RFC v2 2/2] diff.tcl: call \"apply_tab_size 1\" to fix alignment instead of spaces.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-01-27T23:26:25Z","receivedAt":"2026-01-27T23:26:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> By the way, this has nothing to do with your change, but the only\n> existing use of \"apply_tab_size 1\" is also somewhat curious.  When\n> \"proc read_diff\" detects that a patch hunk header has three (not the\n> usual two) at-signs, it calls \"apply_tab_size 1\", presumably to\n> adjust to the fact that combined diff has two leading columns used\n> to signal added/removed/context lines, instead of one.\n>\n> Apparently the author of the original code thought that it is a good\n> idea for such a payload if first tab moves 1 column, and second and\n> subsequent tabs taking gui.tabsize after that tabstop.  A line in\n> combined diff uses two leading columns for line prefix.  Isn't it\n> curious that these two patches under discussion claim that the same\n> exact setting of \"apply_tab_size 1\" is appropriate for _anything_\n> that is shown in the $ui_diff widget prepared with \"proc\n> clear_diff\"?\n>\n> Presumably most of the time, the output format would use just a\n> single leading column for line prefix added (+), removed (-), or\n> context ( ).\n>\n> Both cannot be correct at the same time, can they?\n>\n> So, either the original author is wrong and the current code is\n> broken with or without your change when it shows a combined diff, or\n> these patches is wrong and there is off-by-one bug somwhere.\n>\n> Puzzled and curious ...\n\nApparently the whole thing comes from a43c5f51 (git-gui: add\nconfigurable tab size to the diff view, 2012-02-12).\n\nIt is clear that \"apply_tab_size 0\" is designed for a single-parent\ndiff, while \"apply_tab_size 1\" is designed for two parents diff.  If\nthis new series to make sense, I think it should argue why that\nsetting that users are already familiar with for the past 14 years\nis wrong, and \"apply_tab_size 1\" is more appropriate for a single\nparent diff (and presumably \"apply_tab_size 2\" is better for two\naprent diff), I think.\n\nI do not know if those involved in the original commit are around,\nbut just in case if they remember, I'll CC them.\n\n\ncommit a43c5f51a4b1e56b746295f19daa240283092005\nAuthor: Michael Lutz <michi@icosahedron.de>\nDate:   Sun Feb 12 16:55:17 2012 +0100\n\n    git-gui: add configurable tab size to the diff view\n    \n    For Tk 8.5 the \"wordprocessor\" mode allows us to get a bit fancy for merge\n    diffs and intend the tabs by one to compensate for the additional diff\n    marker at the line start.\n    \n    The code is heavily based on how gitk handles tabs.\n    \n    Signed-off-by: Michael Lutz <michi@icosahedron.de>\n    Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex 6cbb36eab6..bf68699616 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -912,6 +912,7 @@ set default_config(gui.fontdiff) [font configure font_diff]\n set default_config(gui.maxfilesdisplayed) 5000\n set default_config(gui.usettk) 1\n set default_config(gui.warndetachedcommit) 1\n+set default_config(gui.tabsize) 8\n set font_descs {\n \t{fontui   font_ui   {mc \"Main Font\"}}\n \t{fontdiff font_diff {mc \"Diff/Console Font\"}}\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex b0a5180af7..0d56986215 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -1,6 +1,19 @@\n # git-gui diff viewer\n # Copyright (C) 2006, 2007 Shawn Pearce\n \n+proc apply_tab_size {{firsttab {}}} {\n+\tglobal have_tk85 repo_config ui_diff\n+\n+\tset w [font measure font_diff \"0\"]\n+\tif {$have_tk85 && $firsttab != 0} {\n+\t\t$ui_diff configure -tabs [list [expr {$firsttab * $w}] [expr {($firsttab + $repo_config(gui.tabsize)) * $w}]]\n+\t} elseif {$have_tk85 || $repo_config(gui.tabsize) != 8} {\n+\t\t$ui_diff configure -tabs [expr {$repo_config(gui.tabsize) * $w}]\n+\t} else {\n+\t\t$ui_diff configure -tabs {}\n+\t}\n+}\n+\n proc clear_diff {} {\n \tglobal ui_diff current_diff_path current_diff_header\n \tglobal ui_index ui_workdir\n@@ -105,6 +118,8 @@ proc show_diff {path w {lno {}} {scroll_pos {}} {callback {}}} {\n \n \tset cont_info [list $scroll_pos $callback]\n \n+\tapply_tab_size 0\n+\n \tif {[string first {U} $m] >= 0} {\n \t\tmerge_load_stages $path [list show_unmerged_diff $cont_info]\n \t} elseif {$m eq {_O}} {\n@@ -401,7 +416,10 @@ proc read_diff {fd conflict_size cont_info} {\n \n \t\t# -- Automatically detect if this is a 3 way diff.\n \t\t#\n-\t\tif {[string match {@@@ *} $line]} {set is_3way_diff 1}\n+\t\tif {[string match {@@@ *} $line]} {\n+\t\t\tset is_3way_diff 1\n+\t\t\tapply_tab_size 1\n+\t\t}\n \n \t\tif {$::current_diff_inheader} {\n \ndiff --git a/lib/option.tcl b/lib/option.tcl\nindex 23c9ae72a4..b5b6b2fea6 100644\n--- a/lib/option.tcl\n+++ b/lib/option.tcl\n@@ -161,6 +161,7 @@ proc do_options {} {\n \t\t{b gui.warndetachedcommit {mc \"Warn before committing to a detached head\"}}\n \t\t{s gui.stageuntracked {mc \"Staging of untracked files\"} {list \"yes\" \"no\" \"ask\"}}\n \t\t{b gui.displayuntracked {mc \"Show untracked files\"}}\n+\t\t{i-1..99 gui.tabsize {mc \"Tab spacing\"}}\n \t\t} {\n \t\tset type [lindex $option 0]\n \t\tset name [lindex $option 1]\n"},{"id":"534748","messageId":"IY45fwv_UnBCPcj48xZ_Z6wduiXBWyIY71uw9lUY_DjFy7plkb1c980ZdCCMzx1S76QW9NgaXzbpejuVZ1tI4CicRalwL0v3VIiwx20g9Q8=@proton.me","threadId":"64867","inReplyTo":"xmqqfr7qeixq.fsf@gitster.g","subject":"Re: [PATCH/RFC v2 2/2] diff.tcl: call \"apply_tab_size 1\" to fix alignment instead of spaces.","fromName":"GitHub Chris Idema","fromEmail":"github_chris_idema@proton.me","sentAt":"2026-01-28T09:07:11Z","receivedAt":"2026-01-28T09:07:24Z","isPatch":true,"sender":{"key":"github_chris_idema@proton.me","avatar":"https://avatars.githubusercontent.com/u/48433711?v=4"},"body":"> Why does this series first add proc expand_tabs, only to remove its\nuse in this second step?  Shouldn't these two patches be squashed\ninto one, and explain why we want to use \"apply_tab_size 1\" here?\n\nBecause I received feedback on the first commit and realized the \nsecond solution is better. I didn't know you could squash the patches\nones the first one was reviewed. \nI generally don't like rewriting history, but I will be squashing the \ncommits.\nFor some reason Johannes Sixt disappeared from the mailing list. \nI've never used such a clunky interface before. \nI guess linux users like self-flagellation.\n\n> It is clear that \"apply_tab_size 0\" is designed for a single-parent\ndiff, while \"apply_tab_size 1\" is designed for two parents diff. If\nthis new series to make sense, I think it should argue why that\nsetting that users are already familiar with for the past 14 years\nis wrong, and \"apply_tab_size 1\" is more appropriate for a single\nparent diff (and presumably \"apply_tab_size 2\" is better for two\naprent diff), I think.\n\nThe bug has been there for 14 years I guess. In gitk it works as \nexpected.In git diff it works as expected when setting up the pager.\nIn git-gui it doesn't. The alignment is inconsistent with gitk.\nFor code review it's horrible.\nHere is a link to 2 images that show the before and after:\nhttps://github.com/git/git/pull/2179#issuecomment-3799576864\n\n-- Chris\n"},{"id":"534751","messageId":"pull.2179.v3.git.git.1769595640008.gitgitgadget@gmail.com","threadId":"64867","inReplyTo":"pull.2179.v2.git.git.1769545996.gitgitgadget@gmail.com","subject":"[PATCH/RFC v3] diff.tcl: made alignment of tabs in git-gui diff consistent with gitk","fromName":"Chris Idema via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-01-28T10:20:39Z","receivedAt":"2026-01-28T10:20:42Z","isPatch":true,"sender":{"key":"name:Chris Idema","avatar":null},"body":"From: Chris Idema <github_chris_idema@proton.me>\n\nTab stop width was not properly rendered in TK regardless of\ntab width setting. The + or minus character at start of line made\ntabs align incorrectly.\n\nSigned-off-by: Chris Idema <github_chris_idema@proton.me>\n---\n    diff.tcl: made alignment of tabs in git-gui diff consistent with gitk\n    \n    cc: Johannes Sixt j6t@kdbg.org\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2179%2FChrisIdema%2Ffix-gitgui-diff-tab-alignment-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2179/ChrisIdema/fix-gitgui-diff-tab-alignment-v3\nPull-Request: https://github.com/git/git/pull/2179\n\nRange-diff vs v2:\n\n 1:  f2a09c15eb < -:  ---------- diff.tcl: fixed alignment of tabs in git-gui diff by using spaces\n 2:  e11aa6d811 ! 1:  18d25b90c4 diff.tcl: call \"apply_tab_size 1\" to fix alignment instead of spaces.\n     @@ Metadata\n      Author: Chris Idema <github_chris_idema@proton.me>\n      \n       ## Commit message ##\n     -    diff.tcl: call \"apply_tab_size 1\" to fix alignment instead of spaces.\n     +    diff.tcl: made alignment of tabs in git-gui diff consistent with gitk\n     +\n     +    Tab stop width was not properly rendered in TK regardless of\n     +    tab width setting. The + or minus character at start of line made\n     +    tabs align incorrectly.\n      \n          Signed-off-by: Chris Idema <github_chris_idema@proton.me>\n      \n       ## git-gui/lib/diff.tcl ##\n     -@@ git-gui/lib/diff.tcl: proc apply_tab_size {{firsttab {}}} {\n     - \t}\n     - }\n     - \n     --proc expand_tabs {line {startcol -1}} {\n     --\t# startcol set to -1, because in preview the lines start with a '+', '-', or ' '\n     --\tglobal repo_config\n     --\n     --\tset col $startcol\n     --\tset out \"\"\n     --\n     --\tforeach char [split $line \"\"] {\n     --\t\tif {$char eq \"\\t\"} {\n     --\t\t\tset spaces [expr {$repo_config(gui.tabsize) - ($col % $repo_config(gui.tabsize))}]\n     --\t\t\tappend out [string repeat \" \" $spaces]\n     --\t\t\tincr col $spaces\n     --\t\t} else {\n     --\t\t\tappend out $char\n     --\t\t\tincr col\n     --\t\t}\n     --\t}\n     --\n     --\treturn $out\n     --}\n     --\n     - proc clear_diff {} {\n     - \tglobal ui_diff current_diff_path current_diff_header\n     - \tglobal ui_index ui_workdir\n      @@ git-gui/lib/diff.tcl: proc read_diff {fd conflict_size cont_info} {\n       \t\t\t}\n       \t\t}\n       \t\tset mark [$ui_diff index \"end - 1 line linestart\"]\n     --\t\tset line [expand_tabs $line]\n      +\t\tapply_tab_size 1\n     - \t\t$ui_diff insert end \"$line\" $tags\n     --\n     + \t\t$ui_diff insert end $line $tags\n       \t\tif {[string index $line end] eq \"\\r\"} {\n       \t\t\t$ui_diff tag add d_cr {end - 2c}\n     - \t\t}\n\n\n git-gui/lib/diff.tcl | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\nindex 442737ba4f..7da6e5ccae 100644\n--- a/git-gui/lib/diff.tcl\n+++ b/git-gui/lib/diff.tcl\n@@ -495,6 +495,7 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t\t}\n \t\t}\n \t\tset mark [$ui_diff index \"end - 1 line linestart\"]\n+\t\tapply_tab_size 1\n \t\t$ui_diff insert end $line $tags\n \t\tif {[string index $line end] eq \"\\r\"} {\n \t\t\t$ui_diff tag add d_cr {end - 2c}\n\nbase-commit: 1faf5b085a171f9ba9a6d7a446e0de16acccb1dc\n-- \ngitgitgadget\n"},{"id":"534759","messageId":"71494127-c17d-4fd9-a69d-1f547205ac8f@kdbg.org","threadId":"64867","inReplyTo":"xmqqfr7qeixq.fsf@gitster.g","subject":"Re: [PATCH/RFC v2 2/2] diff.tcl: call \"apply_tab_size 1\" to fix alignment instead of spaces.","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2026-01-28T13:40:02Z","receivedAt":"2026-01-28T13:40:12Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 28.01.26 um 00:26 schrieb Junio C Hamano:\n> It is clear that \"apply_tab_size 0\" is designed for a single-parent\n> diff, while \"apply_tab_size 1\" is designed for two parents diff.  If\n> this new series to make sense, I think it should argue why that\n> setting that users are already familiar with for the past 14 years\n> is wrong, and \"apply_tab_size 1\" is more appropriate for a single\n> parent diff (and presumably \"apply_tab_size 2\" is better for two\n> aprent diff), I think.\n\nI concur. Also, \"apply_tab_size 0\" is needed when the contents of an\nunstaged file are shown instead of patch text.\n\n> +proc apply_tab_size {{firsttab {}}} {\n> +\tglobal have_tk85 repo_config ui_diff\n> +\n> +\tset w [font measure font_diff \"0\"]\n> +\tif {$have_tk85 && $firsttab != 0} {\n> +\t\t$ui_diff configure -tabs [list [expr {$firsttab * $w}] [expr {($firsttab + $repo_config(gui.tabsize)) * $w}]]\n\nI think that these values for tabstops aren't optimal. It does not make\nsense to have tabstop at column 1 for diff output, because there is\nalways at least one character ('+', '-', or SP), so that the first tab\nwould jump right to the second stop. In Gitk, the initial version looked\nlike this as well, but it this was changed soon after.\n\n> +\t} elseif {$have_tk85 || $repo_config(gui.tabsize) != 8} {\n> +\t\t$ui_diff configure -tabs [expr {$repo_config(gui.tabsize) * $w}]\n> +\t} else {\n> +\t\t$ui_diff configure -tabs {}\n> +\t}\n> +}\n-- Hannes\n\n"},{"id":"534760","messageId":"Rrnh0ugGQ5ef_s-3W0Tive8HA9R0_9Cq6yK7K6SS6Jr3kPigHai3jzxvphTRNXXNhCnor2TMV8UjKEi5U27VOLBf-R4g6VbJBLq8PQH9kCI=@proton.me","threadId":"64867","inReplyTo":"71494127-c17d-4fd9-a69d-1f547205ac8f@kdbg.org","subject":"Re: [PATCH/RFC v2 2/2] diff.tcl: call \"apply_tab_size 1\" to fix alignment instead of spaces.","fromName":"GitHub Chris Idema","fromEmail":"github_chris_idema@proton.me","sentAt":"2026-01-28T14:02:13Z","receivedAt":"2026-01-28T14:02:24Z","isPatch":true,"sender":{"key":"github_chris_idema@proton.me","avatar":"https://avatars.githubusercontent.com/u/48433711?v=4"},"body":">I concur. Also, \"apply_tab_size 0\" is needed when the contents of an\nunstaged file are shown instead of patch text.\n\nCan you explain why it's needed?\nThe file in my example is unstaged and it's a patch text.\nSo these are not mutually exclusive.\nEven for a staged file the context lines are indented by 1 space \ninstead of a + or - character. So tab stop width is also incorrect \nfor context lines.\nCan you show me how to get content without patch text in the window?\n\n> +\tif {$have_tk85 && $firsttab != 0} {\n\nGives me the error \"can't read \"have_tk85\": no such variable\"\nIf I substitute 1 or 0 for have_tk85 it doesn't fix the alignment.\n\nI'm open for suggestions. My 1 line code change fixes the problem,\nbut if it is not the official way to do it or if it introduces other\nproblems feel free to suggest another fix.\n\nFor reference here are the screenshots of the problem:\nhttps://github.com/git/git/pull/2179#issuecomment-3799576864\n\nFor us this bug is a show stopper that makes the diff in the\ngit-gui window by default unreadable.\n\n-- Chris\n\nOn Wednesday, January 28th, 2026 at 14:40, Johannes Sixt <j6t@kdbg.org> wrote:\n\n> Am 28.01.26 um 00:26 schrieb Junio C Hamano:\n> \n> > It is clear that \"apply_tab_size 0\" is designed for a single-parent\n> > diff, while \"apply_tab_size 1\" is designed for two parents diff. If\n> > this new series to make sense, I think it should argue why that\n> > setting that users are already familiar with for the past 14 years\n> > is wrong, and \"apply_tab_size 1\" is more appropriate for a single\n> > parent diff (and presumably \"apply_tab_size 2\" is better for two\n> > aprent diff), I think.\n> \n> \n> I concur. Also, \"apply_tab_size 0\" is needed when the contents of an\n> unstaged file are shown instead of patch text.\n> \n> > +proc apply_tab_size {{firsttab {}}} {\n> > + global have_tk85 repo_config ui_diff\n> > +\n> > + set w [font measure font_diff \"0\"]\n> > + if {$have_tk85 && $firsttab != 0} {\n> > + $ui_diff configure -tabs [list [expr {$firsttab * $w}] [expr {($firsttab + $repo_config(gui.tabsize)) * $w}]]\n> \n> \n> I think that these values for tabstops aren't optimal. It does not make\n> sense to have tabstop at column 1 for diff output, because there is\n> always at least one character ('+', '-', or SP), so that the first tab\n> would jump right to the second stop. In Gitk, the initial version looked\n> like this as well, but it this was changed soon after.\n> \n> > + } elseif {$have_tk85 || $repo_config(gui.tabsize) != 8} {\n> > + $ui_diff configure -tabs [expr {$repo_config(gui.tabsize) * $w}]\n> > + } else {\n> > + $ui_diff configure -tabs {}\n> > + }\n> > +}\n> \n> -- Hannes\n"},{"id":"534768","messageId":"bf8e6231-e1c0-4c0c-b4d5-20f8d0044211@kdbg.org","threadId":"64867","inReplyTo":"Rrnh0ugGQ5ef_s-3W0Tive8HA9R0_9Cq6yK7K6SS6Jr3kPigHai3jzxvphTRNXXNhCnor2TMV8UjKEi5U27VOLBf-R4g6VbJBLq8PQH9kCI=@proton.me","subject":"Re: [PATCH/RFC v2 2/2] diff.tcl: call \"apply_tab_size 1\" to fix alignment instead of spaces.","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2026-01-28T15:59:55Z","receivedAt":"2026-01-28T16:00:04Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 28.01.26 um 15:02 schrieb GitHub Chris Idema:\n>> I concur. Also, \"apply_tab_size 0\" is needed when the contents of\n>> an unstaged file are shown instead of patch text.\n> \n> Can you explain why it's needed?\n> The file in my example is unstaged and it's a patch text.\n> ...\n> Can you show me how to get content without patch text in the window?\n\nSorry, I meant \"untracked file\". When the text of an untracked file is\ndisplayed, we do not want to offset the tabstops.\n\n> \n>> +\tif {$have_tk85 && $firsttab != 0} {\n> \n> Gives me the error \"can't read \"have_tk85\": no such variable\"\n> If I substitute 1 or 0 for have_tk85 it doesn't fix the alignment.\n\nThis was not a suggested fix, but a citation of the patch that\nintroduced the function. The variable has since been eliminated.\n\n> I'm open for suggestions. My 1 line code change fixes the problem,\n> but if it is not the official way to do it or if it introduces other\n> problems feel free to suggest another fix.\n\nIt may fix the problem for regular patch text. But I doubt that it is a\ncorrect fix for combined-diff text, because that needs offset 2.\n\n> For us this bug is a show stopper that makes the diff in the\n> git-gui window by default unreadable.\n\nEarlier, I said that I'm not fond of such a change. But I changed my\nmind. I hadn't noticed so far that Gitk applies customized tabstops. Git\nGUI and Gitk need not emulate the behavor of terminal windows faithfully\nand can be more clever as far as tabstops are concerned.\n\n-- Hannes\n\n"},{"id":"534770","messageId":"547d261c-a716-4c57-8b93-09cf7d8fb176@kdbg.org","threadId":"64867","inReplyTo":"pull.2179.v3.git.git.1769595640008.gitgitgadget@gmail.com","subject":"Re: [PATCH/RFC v3] diff.tcl: made alignment of tabs in git-gui diff consistent with gitk","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2026-01-28T17:02:00Z","receivedAt":"2026-01-28T17:02:04Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 28.01.26 um 11:20 schrieb Chris Idema via GitGitGadget:\n> From: Chris Idema <github_chris_idema@proton.me>\n> \n> Tab stop width was not properly rendered in TK regardless of\n> tab width setting. The + or minus character at start of line made\n> tabs align incorrectly.\n\nThis is a patch for Git GUI. Please use the subject prefix \"git-gui:\".\nThe file name need not be mentioned.\n\nPlease have a look at existing commits and mimic the style of the commit\nsubject and body text. In particular:\n\n- Use present tense to describe the current state. Elaborate what the\nproblem is. Assume that readers haven't looked at the code for some time\nand guide them to the problem point (i.e., provide some context).\n\n- Use imperative mood to describe the change as if you instruct someone\nto make the change.\n\nI suggest this subject:\n\ngit-gui: shift tabstops to account for the first column of context diffs\n\n> \n> Signed-off-by: Chris Idema <github_chris_idema@proton.me>\n> ---\n>     diff.tcl: made alignment of tabs in git-gui diff consistent with gitk\n>     \n>     cc: Johannes Sixt j6t@kdbg.org\n\nJust FYI, this message didn't arrive in my mailbox despite this line.\n\n> diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\n> index 442737ba4f..7da6e5ccae 100644\n> --- a/git-gui/lib/diff.tcl\n> +++ b/git-gui/lib/diff.tcl\n> @@ -495,6 +495,7 @@ proc read_diff {fd conflict_size cont_info} {\n>  \t\t\t}\n>  \t\t}\n>  \t\tset mark [$ui_diff index \"end - 1 line linestart\"]\n> +\t\tapply_tab_size 1\n>  \t\t$ui_diff insert end $line $tags\n>  \t\tif {[string index $line end] eq \"\\r\"} {\n>  \t\t\t$ui_diff tag add d_cr {end - 2c}\n\nIf you look at commit a43c5f51a4b1, you will notice that it intended to\napply \"magic\" tabstops only to 3-way-diffs. It did not intend to \"fix\"\nregular patch text. Without the change, 3-way-diffs would become even\nmore misaligned, because these have two initial positions instead of\njust one. To fix the additional misalignment, it applies the offset 1 to\nthe tabstops. But this does not fix the original misalignment.\n\nYou now want to fix the original misalignment. Therefore, you have to\napply the offset 1 for regular patch text, but offset 2 to 3-way-diffs.\nAnd, in addition, no offset if file contents are displayed.\n\n-- Hannes\n\n"},{"id":"534771","messageId":"ltvoMavyjgCl1Axuv1HV0rBdQPT2AcZQi4z9mo50OHYwoJ6pjCqEmdWfTmv2YHVSQjYxk2HSdxBXjTTKysBJ2CkdPotiOUIkUSnOMyOvLPU=@proton.me","threadId":"64867","inReplyTo":"547d261c-a716-4c57-8b93-09cf7d8fb176@kdbg.org","subject":"Re: [PATCH/RFC v3] diff.tcl: made alignment of tabs in git-gui diff consistent with gitk","fromName":"GitHub Chris Idema","fromEmail":"github_chris_idema@proton.me","sentAt":"2026-01-28T19:02:56Z","receivedAt":"2026-01-28T19:03:07Z","isPatch":true,"sender":{"key":"github_chris_idema@proton.me","avatar":"https://avatars.githubusercontent.com/u/48433711?v=4"},"body":"> This is a patch for Git GUI. Please use the subject prefix \"git-gui:\".\nThe file name need not be mentioned.\n\nThank you.\n\n>If you look at commit a43c5f51a4b1, you will notice that it intended to\napply \"magic\" tabstops only to 3-way-diffs\n\nI see it now.\nI was able to test:\n- \"Modified, not staged\", needs \"apply_tab_size 1\"\n- \"Staged for commit\", needs \"apply_tab_size 1\"\n- \"Requires merge resolution\", doesn't work and needs \"apply_tab_size 2\"\n- \"Untracked, not staged\", handled somewhere else, works\n- \"Missing\", needs \"apply_tab_size 1\"\n- \"Staged for removal\", needs \"apply_tab_size 1\"\n\nSo I need to make some changes.\n\n-- Chris\n"},{"id":"534787","messageId":"xmqq4io5e23t.fsf@gitster.g","threadId":"64867","inReplyTo":"bf8e6231-e1c0-4c0c-b4d5-20f8d0044211@kdbg.org","subject":"Re: [PATCH/RFC v2 2/2] diff.tcl: call \"apply_tab_size 1\" to fix alignment instead of spaces.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-01-28T23:42:14Z","receivedAt":"2026-01-28T23:42:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n>> For us this bug is a show stopper that makes the diff in the\n>> git-gui window by default unreadable.\n\n> Earlier, I said that I'm not fond of such a change. But I changed my\n> mind. I hadn't noticed so far that Gitk applies customized tabstops. Git\n> GUI and Gitk need not emulate the behavor of terminal windows faithfully\n> and can be more clever as far as tabstops are concerned.\n\nI just peeked what gitk does, and it does use \"settabs 0\" (the\nequivalent of \"apply_tab_size 0\" in gitk world) for plain files,\n\"settabs 1\" for one parent regular commits, and \"settabs $np\" for\nn-parent merges, so what Chris is doing here makes git-gui match\nwhat gitk has been doing since 32f1b3e4 (gitk: Fix the tab setting\nin the diff display window, 2007-09-28) for close to 20 years ;-).\n\nHaving said that, the fact that they have been allowed to be\ndifferent for so long tells me that the way characters immediately\nafter tabs have been displayed in git-gui bothered nobody for a long\ntime, and calling it a \"show stopper\" and \"unreadable\" is a great\nexaggeration, I must say.\n\nThanks.\n"},{"id":"534793","messageId":"xmqqzf5xcmm2.fsf@gitster.g","threadId":"64867","inReplyTo":"pull.2179.v3.git.git.1769595640008.gitgitgadget@gmail.com","subject":"Re: [PATCH/RFC v3] diff.tcl: made alignment of tabs in git-gui diff consistent with gitk","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-01-29T00:02:13Z","receivedAt":"2026-01-29T00:02:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Chris Idema via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Chris Idema <github_chris_idema@proton.me>\n>\n> Tab stop width was not properly rendered in TK regardless of\n> tab width setting. The + or minus character at start of line made\n> tabs align incorrectly.\n\nIf git-gui has a feature to show file contents, not comparison of\nthe old and the new versions of a file as a diff, there won't be\nplus or minus at the beginning.  The above paragraph of course is\nmostly OK, but it would be more helpful to qualify it by talking\nabout \"diff\" somewhere.\n\n    Because the diff view spends the leftmost column for plus sign\n    for added line, minus sign for removed line, etc., a tab that\n    would push the next character to multiple of 8 (or gui.tabsize)\n    column may appear narrower by 1 column.\n\n    Compensate for this by setting tabstops at 9th, 17th, 25th,\n    ... columns (or 1+multiple of gui.tabsize) for showing a single\n    parent diff, and shift by 2 columns for showing a two parent\n    diff.\n\nor something.\n\nI noticed that gitk has code to deal with octopus merges (i.e., a\nmerge does not necessarily have two parents, but it is possible to\nhave more parents), but git-gui assumes that merges with two parents\nare the only ones that are worth caring about.  Correcting for this\nmay be almost trivial, but I do not think it falls into the scope of\nthis topic.  But at least I think this topic should adjust existing\n\"apply_tab_size 1\" used for two-parent merge combined diff to use 2.\n\n>  git-gui/lib/diff.tcl | 1 +\n>  1 file changed, 1 insertion(+)\n>\n> diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\n> index 442737ba4f..7da6e5ccae 100644\n> --- a/git-gui/lib/diff.tcl\n> +++ b/git-gui/lib/diff.tcl\n> @@ -495,6 +495,7 @@ proc read_diff {fd conflict_size cont_info} {\n>  \t\t\t}\n>  \t\t}\n>  \t\tset mark [$ui_diff index \"end - 1 line linestart\"]\n> +\t\tapply_tab_size 1\n>  \t\t$ui_diff insert end $line $tags\n>  \t\tif {[string index $line end] eq \"\\r\"} {\n>  \t\t\t$ui_diff tag add d_cr {end - 2c}\n>\n> base-commit: 1faf5b085a171f9ba9a6d7a446e0de16acccb1dc\n"},{"id":"534794","messageId":"xmqqv7glcmee.fsf@gitster.g","threadId":"64867","inReplyTo":"71494127-c17d-4fd9-a69d-1f547205ac8f@kdbg.org","subject":"Re: [PATCH/RFC v2 2/2] diff.tcl: call \"apply_tab_size 1\" to fix alignment instead of spaces.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-01-29T00:06:49Z","receivedAt":"2026-01-29T00:06:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n> I think that these values for tabstops aren't optimal. It does not make\n> sense to have tabstop at column 1 for diff output, because there is\n> always at least one character ('+', '-', or SP), so that the first tab\n> would jump right to the second stop. In Gitk, the initial version looked\n> like this as well, but it this was changed soon after.\n\nTrue.  So instead of setting tabstops at 1, 9, 17, 25, ..., gitk\ndoes 9, 17, 25, 33, ..., which makes more sense, but there is no\npractical difference, no?  Because the first column will be the\nplus, minus, or space and it will never be a tab.\n\n"},{"id":"534800","messageId":"AXTzN5mRXdWYZx55ARuBbRgndXW5zA51_wcnAV4KaUpk3kz6t8ZYfOk0Du5rg6zKhz0_O-4ZSkLNX6WkhTp4fjDFDMfCZAsTRCoBMH_IpMU=@proton.me","threadId":"64867","inReplyTo":"xmqqv7glcmee.fsf@gitster.g","subject":"Re: [PATCH/RFC v2 2/2] diff.tcl: call \"apply_tab_size 1\" to fix alignment instead of spaces.","fromName":"GitHub Chris Idema","fromEmail":"github_chris_idema@proton.me","sentAt":"2026-01-29T08:31:24Z","receivedAt":"2026-01-29T08:31:38Z","isPatch":true,"sender":{"key":"github_chris_idema@proton.me","avatar":"https://avatars.githubusercontent.com/u/48433711?v=4"},"body":"> From: Junio C Hamano <gitster@pobox.com>\n>\n> calling it a \"show stopper\" and \"unreadable\" is a great\n> exaggeration, I must say.\n\nWe use clang-format to format most of our code.\nBut we don't have that always available.\nSo it's good to review indentation changes prior to commit.\nAnd we use either git diff or Git Gui for that.\nFor many file changes I prefer Git Gui as you don't need to scroll.\n\nFor git diff there is a way to configure tab size to 4:\ngit config --global core.pager 'less -x1,5'\nsource: https://stackoverflow.com/a/10584237/15307950\n\nFor Git Gui and Gitk there is also a tab setting.\nBut only in Git Gui it didn't work as expected.\nSo with show stopper I meant that it's the only odd one.\nAnd since the code already uses apply_tab_size it makes sense to just \napply it correctly in all scenarios.\n\nMy latest commit was tested for:\n- \"Modified, not staged\"\n- \"Staged for commit\"\n- \"Requires merge resolution\"\n- \"Untracked, not staged\"\n- \"Missing\"\n- \"Staged for removal\"\n\nAnd it worked on my side. \n@@@ needs apply_tab_size 2\n@@ needs apply_tab_size 1\nthe rest was already handled correctly\n\n> From: Junio C Hamano <gitster@pobox.com>\n>\n> I noticed that gitk has code to deal with octopus merges\n\nI would love to know how such a merge can be replicated.\nIs it also possible to have such a merge visible in Git Gui?\n\n-- Chris\n"},{"id":"534801","messageId":"7f45bdc4-d164-42e4-8a84-36410654b4e0@kdbg.org","threadId":"64867","inReplyTo":"AXTzN5mRXdWYZx55ARuBbRgndXW5zA51_wcnAV4KaUpk3kz6t8ZYfOk0Du5rg6zKhz0_O-4ZSkLNX6WkhTp4fjDFDMfCZAsTRCoBMH_IpMU=@proton.me","subject":"Re: [PATCH/RFC v2 2/2] diff.tcl: call \"apply_tab_size 1\" to fix alignment instead of spaces.","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2026-01-29T10:04:46Z","receivedAt":"2026-01-29T10:05:02Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 29.01.26 um 09:31 schrieb GitHub Chris Idema:\n>> From: Junio C Hamano <gitster@pobox.com>\n>> I noticed that gitk has code to deal with octopus merges\n> \n> I would love to know how such a merge can be replicated.\n> Is it also possible to have such a merge visible in Git Gui?\nThis case is not relevant for Git GUI, because it can only show what is\nin the index. We have only \"theirs\" and \"ours\", and together with the\ncurrent file contents that's a 3-way diff.\n\n-- Hannes\n\n"},{"id":"534804","messageId":"pull.2179.v4.git.git.1769684944593.gitgitgadget@gmail.com","threadId":"64867","inReplyTo":"pull.2179.v3.git.git.1769595640008.gitgitgadget@gmail.com","subject":"[PATCH v4] git-gui: shift tabstops to account for the first column of context diffs","fromName":"Chris Idema via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-01-29T11:09:04Z","receivedAt":"2026-01-29T11:09:07Z","isPatch":true,"sender":{"key":"name:Chris Idema","avatar":null},"body":"From: Chris Idema <github_chris_idema@proton.me>\n\nWhen reviewing a file before staging you want its content aligned using\ngui.tabsize. The prefixing of lines with +, - or space characters should\nnot change this alignment. In gitk this is done correctly. In Git Gui not.\n\nSigned-off-by: Chris Idema <github_chris_idema@proton.me>\n---\n    git-gui: shift tabstops to account for the first column of context diffs\n    \n    cc: Johannes Sixt j6t@kdbg.org\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2179%2FChrisIdema%2Ffix-gitgui-diff-tab-alignment-v4\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2179/ChrisIdema/fix-gitgui-diff-tab-alignment-v4\nPull-Request: https://github.com/git/git/pull/2179\n\nRange-diff vs v3:\n\n 1:  18d25b90c4 ! 1:  1c91363568 diff.tcl: made alignment of tabs in git-gui diff consistent with gitk\n     @@ Metadata\n      Author: Chris Idema <github_chris_idema@proton.me>\n      \n       ## Commit message ##\n     -    diff.tcl: made alignment of tabs in git-gui diff consistent with gitk\n     +    git-gui: shift tabstops to account for the first column of context diffs\n      \n     -    Tab stop width was not properly rendered in TK regardless of\n     -    tab width setting. The + or minus character at start of line made\n     -    tabs align incorrectly.\n     +    When reviewing a file before staging you want its content aligned using\n     +    gui.tabsize. The prefixing of lines with +, - or space characters should\n     +    not change this alignment. In gitk this is done correctly. In Git Gui not.\n      \n          Signed-off-by: Chris Idema <github_chris_idema@proton.me>\n      \n       ## git-gui/lib/diff.tcl ##\n      @@ git-gui/lib/diff.tcl: proc read_diff {fd conflict_size cont_info} {\n     - \t\t\t}\n     + \t\t#\n     + \t\tif {[string match {@@@ *} $line]} {\n     + \t\t\tset is_3way_diff 1\n     ++\t\t\tapply_tab_size 2\n     ++\t\t} elseif {[string match {@@ *} $line]} {\n     + \t\t\tapply_tab_size 1\n       \t\t}\n     - \t\tset mark [$ui_diff index \"end - 1 line linestart\"]\n     -+\t\tapply_tab_size 1\n     - \t\t$ui_diff insert end $line $tags\n     - \t\tif {[string index $line end] eq \"\\r\"} {\n     - \t\t\t$ui_diff tag add d_cr {end - 2c}\n     + \n\n\n git-gui/lib/diff.tcl | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\nindex 442737ba4f..8be1a613fb 100644\n--- a/git-gui/lib/diff.tcl\n+++ b/git-gui/lib/diff.tcl\n@@ -385,6 +385,8 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t#\n \t\tif {[string match {@@@ *} $line]} {\n \t\t\tset is_3way_diff 1\n+\t\t\tapply_tab_size 2\n+\t\t} elseif {[string match {@@ *} $line]} {\n \t\t\tapply_tab_size 1\n \t\t}\n \n\nbase-commit: 1faf5b085a171f9ba9a6d7a446e0de16acccb1dc\n-- \ngitgitgadget\n"},{"id":"534816","messageId":"xmqqikckcutb.fsf@gitster.g","threadId":"64867","inReplyTo":"7f45bdc4-d164-42e4-8a84-36410654b4e0@kdbg.org","subject":"Re: [PATCH/RFC v2 2/2] diff.tcl: call \"apply_tab_size 1\" to fix alignment instead of spaces.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-01-29T15:17:20Z","receivedAt":"2026-01-29T15:17:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n> Am 29.01.26 um 09:31 schrieb GitHub Chris Idema:\n>>> From: Junio C Hamano <gitster@pobox.com>\n>>> I noticed that gitk has code to deal with octopus merges\n>> \n>> I would love to know how such a merge can be replicated.\n>> Is it also possible to have such a merge visible in Git Gui?\n> This case is not relevant for Git GUI, because it can only show what is\n> in the index. We have only \"theirs\" and \"ours\", and together with the\n> current file contents that's a 3-way diff.\n\nOK.  If it does not show existing merge commits, then I agree that\nonly 3-way is relevant.  Thanks for a clarification.\n"},{"id":"534839","messageId":"191b6fe4-e273-4ecd-9b73-725c2dff4306@kdbg.org","threadId":"64867","inReplyTo":"pull.2179.v4.git.git.1769684944593.gitgitgadget@gmail.com","subject":"Re: [PATCH v4] git-gui: shift tabstops to account for the first column of context diffs","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2026-01-29T21:36:20Z","receivedAt":"2026-01-29T21:36:31Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 29.01.26 um 12:09 schrieb Chris Idema via GitGitGadget:\n> From: Chris Idema <github_chris_idema@proton.me>\n> \n> When reviewing a file before staging you want its content aligned using\n> gui.tabsize. The prefixing of lines with +, - or space characters should\n> not change this alignment. In gitk this is done correctly. In Git Gui not.\n> \n> Signed-off-by: Chris Idema <github_chris_idema@proton.me>\n> ---\n\n> \n>  git-gui/lib/diff.tcl | 2 ++\n>  1 file changed, 2 insertions(+)\n> \n> diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\n> index 442737ba4f..8be1a613fb 100644\n> --- a/git-gui/lib/diff.tcl\n> +++ b/git-gui/lib/diff.tcl\n> @@ -385,6 +385,8 @@ proc read_diff {fd conflict_size cont_info} {\n>  \t\t#\n>  \t\tif {[string match {@@@ *} $line]} {\n>  \t\t\tset is_3way_diff 1\n> +\t\t\tapply_tab_size 2\n> +\t\t} elseif {[string match {@@ *} $line]} {\n>  \t\t\tapply_tab_size 1\n>  \t\t}\n>  \nJust \"else\" without a condition would have been sufficient, but we can\ndo it this way as well.\n\nI've rewritten the commit message like so:\n\n    git-gui: shift tabstops to account for the first column of patch text\n    \n    When reviewing a change before staging, it is desirable to see text after\n    tabstops aligned the same way as in the text editor. However, since there\n    is always an additional character in column one in patch text ('+', '-',\n    or space), the alignment is broken if text before the first tab character\n    is just long enough to push the stop to the next tab position.\n    \n    Commit a43c5f51a4b1 (git-gui: add configurable tab size to the diff view,\n    2012-02-12) added infrastructure that manipulates the tabstop positions\n    of the Tk text widget. However, it does so only when a 3-way diff is\n    shown and only so that it takes into account the one additional markup at\n    the beginning of lines. This only achieved that alignment does not get\n    worse for 3-way diffs compared to regular patch text, but left misaligned\n    text in regular patch text unmodified.\n    \n    Use and modify this infrastructure to shift tabstops by one position for\n    regular patch text and two positions for 3-way diffs. Existing code\n    already resets the tabstops to an unshifted position when contents of\n    untracked files are displayed.\n    \n    Signed-off-by: Chris Idema <github_chris_idema@proton.me>\n    [j6t: extend commit message]\n    Signed-off-by: Johannes Sixt <j6t@kdbg.org>\n\nIn particular there was no bug; this is a new feature.\n\nThanks,\n-- Hannes\n\n"},{"id":"537778","messageId":"Hf23ZjoLMdkhr77C9rfhukpwi1zKpjyEwhMPfsqHbL4Cqruu8WRHHeFrX7mtPzxbmV3uyEgK5yXDBxUUVparcHo0f3PSipKEfTipswpYC68=@proton.me","threadId":"64867","inReplyTo":"191b6fe4-e273-4ecd-9b73-725c2dff4306@kdbg.org","subject":"Re: [PATCH v4] git-gui: shift tabstops to account for the first column of context diffs","fromName":"GitHub Chris Idema","fromEmail":"github_chris_idema@proton.me","sentAt":"2026-03-04T13:32:20Z","receivedAt":"2026-03-04T13:32:30Z","isPatch":true,"sender":{"key":"github_chris_idema@proton.me","avatar":"https://avatars.githubusercontent.com/u/48433711?v=4"},"body":"Any updates? I see it hasn't been merged yet.\n\nChris Idema\n\n-------- Original Message --------\nOn Thursday, 01/29/26 at 22:36 Johannes Sixt <j6t@kdbg.org> wrote:\nAm 29.01.26 um 12:09 schrieb Chris Idema via GitGitGadget:\n> From: Chris Idema <github_chris_idema@proton.me>\n>\n> When reviewing a file before staging you want its content aligned using\n> gui.tabsize. The prefixing of lines with +, - or space characters should\n> not change this alignment. In gitk this is done correctly. In Git Gui not.\n>\n> Signed-off-by: Chris Idema <github_chris_idema@proton.me>\n> ---\n\n>\n>  git-gui/lib/diff.tcl | 2 ++\n>  1 file changed, 2 insertions(+)\n>\n> diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\n> index 442737ba4f..8be1a613fb 100644\n> --- a/git-gui/lib/diff.tcl\n> +++ b/git-gui/lib/diff.tcl\n> @@ -385,6 +385,8 @@ proc read_diff {fd conflict_size cont_info} {\n>  \t\t#\n>  \t\tif {[string match {@@@ *} $line]} {\n>  \t\t\tset is_3way_diff 1\n> +\t\t\tapply_tab_size 2\n> +\t\t} elseif {[string match {@@ *} $line]} {\n>  \t\t\tapply_tab_size 1\n>  \t\t}\n>\nJust \"else\" without a condition would have been sufficient, but we can\ndo it this way as well.\n\nI've rewritten the commit message like so:\n\n    git-gui: shift tabstops to account for the first column of patch text\n\n    When reviewing a change before staging, it is desirable to see text after\n    tabstops aligned the same way as in the text editor. However, since there\n    is always an additional character in column one in patch text ('+', '-',\n    or space), the alignment is broken if text before the first tab character\n    is just long enough to push the stop to the next tab position.\n\n    Commit a43c5f51a4b1 (git-gui: add configurable tab size to the diff view,\n    2012-02-12) added infrastructure that manipulates the tabstop positions\n    of the Tk text widget. However, it does so only when a 3-way diff is\n    shown and only so that it takes into account the one additional markup at\n    the beginning of lines. This only achieved that alignment does not get\n    worse for 3-way diffs compared to regular patch text, but left misaligned\n    text in regular patch text unmodified.\n\n    Use and modify this infrastructure to shift tabstops by one position for\n    regular patch text and two positions for 3-way diffs. Existing code\n    already resets the tabstops to an unshifted position when contents of\n    untracked files are displayed.\n\n    Signed-off-by: Chris Idema <github_chris_idema@proton.me>\n    [j6t: extend commit message]\n    Signed-off-by: Johannes Sixt <j6t@kdbg.org>\n\nIn particular there was no bug; this is a new feature.\n\nThanks,\n-- Hannes\n\n\n"},{"id":"537831","messageId":"4c3acb06-dea0-4402-b466-e3775a2fd866@kdbg.org","threadId":"64867","inReplyTo":"Hf23ZjoLMdkhr77C9rfhukpwi1zKpjyEwhMPfsqHbL4Cqruu8WRHHeFrX7mtPzxbmV3uyEgK5yXDBxUUVparcHo0f3PSipKEfTipswpYC68=@proton.me","subject":"Re: [PATCH v4] git-gui: shift tabstops to account for the first column of context diffs","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2026-03-04T19:22:10Z","receivedAt":"2026-03-04T19:22:19Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 04.03.26 um 14:32 schrieb GitHub Chris Idema:\n> Any updates? I see it hasn't been merged yet.\n\nSee https://github.com/j6t/git-gui/commits/master/. I'll send the\npatch(es) upstream in due time.\n\n-- Hannes\n\n"}]}