Skip to contentSkip to conversation

gitk: don't highlight files after submodules as submodules

PATCH In review Роман Донченко 2 participants 2 messages Nov 1, 2019 – Dec 15, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitk: don't highlight files after submodules as submodules

gitk applies submodule highlighting (coloring lines starting with " >" and " <") when currdiffsubmod is not an empty string. However, it fails to reset currdiffsubmod after a submodule diff ends, so any file diffs following a submodule diff will still be highlighted as if they were submodule diffs.

There are two problems with the way gitk tries to reset currdiffsubmod:

1. The code says set $currdiffsubmod instead of set currdiffsubmod, so it actually sets the variable whose name is the submodule path instead.

2. It tries to do it after the first line in a submodule diff, which is incorrect, since submodule diffs can contain multiple lines.

Fix this by resetting currdiffsubmod when a file diff starts.

---
 gitk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
gitk +2 -2
index abe4805..7c425d2 100755
@@ -8146,6 +8146,8 @@ proc parseblobdiffline {ids line} {
 	}
 	# start of a new file
 	set diffinhdr 1
+	set currdiffsubmod ""
+
 	$ctext insert end "\n"
 	set curdiffstart [$ctext index "end - 1c"]
 	lappend ctext_file_names ""
@@ -8229,11 +8231,9 @@ proc parseblobdiffline {ids line} {
 	    $ctext insert end "$line\n" filesep
 	}
     } elseif {$currdiffsubmod != "" && ![string compare -length 3 "  >" $line]} {
-	set $currdiffsubmod ""
 	set line [encoding convertfrom $diffencoding $line]
 	$ctext insert end "$line\n" dresult
     } elseif {$currdiffsubmod != "" && ![string compare -length 3 "  <" $line]} {
-	set $currdiffsubmod ""
 	set line [encoding convertfrom $diffencoding $line]
 	$ctext insert end "$line\n" d0
     } elseif {$diffinhdr} {
Signature · 1 line
2.19.1.windows.1
#1 lore raw
Quoted 12 lines · Роман Донченко

gitk applies submodule highlighting (coloring lines starting with " >" and " <") when currdiffsubmod is not an empty string. However, it fails to reset currdiffsubmod after a submodule diff ends, so any file diffs following a submodule diff will still be highlighted as if they were submodule diffs.

There are two problems with the way gitk tries to reset currdiffsubmod:

1. The code says set $currdiffsubmod instead of set currdiffsubmod, so it actually sets the variable whose name is the submodule path instead.

Quoted 6 lines

2. It tries to do it after the first line in a submodule diff, which is incorrect, since submodule diffs can contain multiple lines.

Fix this by resetting currdiffsubmod when a file diff starts.

Thanks, patch applied.

Paul.