gitk: don't highlight submodule diff lines outside submodule diffs
PATCH 1/1 gitk: don't highlight submodule diff lines outside submodule diffs
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.
--- gitk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
gitk +4 -4
@@ -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} {
Signature · 1 line
2.19.1.windows.1
Quoted 7 lines · Роман Донченко
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.
This explanation makes sense, some prior art is at
https://public-inbox.org/git/[email protected]/
which was not taken AFAICT.
Thanks,
Stefan
Quoted 37 lines
Signed-off-by Роман Донченко <[email protected]>--- gitk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)gitk +4
-5@@ -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
06.11.2018 23:06, Stefan Beller пишет:
Quoted 6 lines · Роман Донченко
Quoted 5 lines
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.
Quoted 6 lines
Quoted 2 lines
Use the currdiffsubmod variable to track whether we are currently inside a submodule diff and only highlight these lines if we are.
This explanation makes sense, some prior art is at
https://public-inbox.org/git/[email protected]/
which was not taken AFAICT.
Didn't see that patch. That said, I think it's incorrect, since it never resets currdiffsubmod back to the empty string, so if a normal diff follows a submodule diff, the same issue will occur.
(The set $currdiffsubmod "" lines that are already there are effectively useless because they set the variable whose name is the contents of currdiffsubmod, rather than currdiffsubmod itself. I assume it was a typo.)
-Roman
Quoted 41 lines
Thanks,
StefanQuoted 37 lines
Signed-off-by Роман Донченко <[email protected]>--- gitk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)gitk +4
-5@@ -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