]> git.ipfire.org Git - thirdparty/git.git/commitdiff
gitk: don't highlight files after submodules as submodules
authorРоман Донченко <dpb@corrigendum.ru>
Fri, 1 Nov 2019 23:34:27 +0000 (02:34 +0300)
committerPaul Mackerras <paulus@ozlabs.org>
Sun, 15 Dec 2019 04:30:50 +0000 (15:30 +1100)
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.

Signed-off-by: Роман Донченко <dpb@corrigendum.ru>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
gitk

diff --git a/gitk b/gitk
index 888ea5dcb20b8601baefeab4fb3d98e94e5a6b63..1a234fef1d653bc1c1cc3a419110a87098ba0f02 100755 (executable)
--- a/gitk
+++ b/gitk
@@ -8150,6 +8150,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 ""
@@ -8233,11 +8235,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} {