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

[PATCH] gitk: don't highlight submodule diff lines outside submodule diffs

From
Роман Донченко <dpb@corrigendum.ru>
Date
Nov 6, 2018, 19:54 UTC
Message-ID
<20181106195417.5456-1-dpb@corrigendum.ru>

A line that starts with " <" or " >" is not necessarily a submodule diff line. It might just be a context line in a normal diff, representing a line starting with " <" or " >" respectively.

Use the currdiffsubmod variable to track whether we are currently inside a submodule diff and only highlight these lines if we are.

Signed-off-by: Роман Донченко <dpb@corrigendum.ru>
---
 gitk | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gitk b/gitk
index a14d7a1..6bb6dc6 100755
--- a/gitk
+++ b/gitk
@@ -8109,6 +8109,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 ""
@@ -8191,12 +8193,10 @@ proc parseblobdiffline {ids line} {
 	} else {
 	    $ctext insert end "$line\n" filesep
 	}
-    } elseif {![string compare -length 3 "  >" $line]} {
-	set $currdiffsubmod ""
+    } elseif {$currdiffsubmod ne "" && ![string compare -length 3 "  >" $line]} {
 	set line [encoding convertfrom $diffencoding $line]
 	$ctext insert end "$line\n" dresult
-    } elseif {![string compare -length 3 "  <" $line]} {
-	set $currdiffsubmod ""
+    } elseif {$currdiffsubmod ne "" && ![string compare -length 3 "  <" $line]} {
 	set line [encoding convertfrom $diffencoding $line]
 	$ctext insert end "$line\n" d0
     } elseif {$diffinhdr} {
-- 
2.19.1.windows.1
Next: Stefan Beller
Message 1 of 3 in “gitk: don't highlight submodule diff lines outside submodule diffs”
  1. gitk: don't highlight submodule diff lines outside submodule diffsРоман Донченко, Nov 6, 2018
  2. Stefan BellerNov 6, 2018
  3. Роман ДонченкоNov 6, 2018

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.