git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] gitk: don't highlight submodule diff lines outside submodule diffs
@ 2018-11-06 19:54 Роман Донченко
  2018-11-06 20:06 ` Stefan Beller
  0 siblings, 1 reply; 3+ messages in thread
From: Роман Донченко @ 2018-11-06 19:54 UTC (permalink / raw)
  To: git
  Cc: paulus,
	Роман Донченко

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] gitk: don't highlight submodule diff lines outside submodule diffs
  2018-11-06 19:54 [PATCH] gitk: don't highlight submodule diff lines outside submodule diffs Роман Донченко
@ 2018-11-06 20:06 ` Stefan Beller
  2018-11-06 21:56   ` Роман Донченко
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Beller @ 2018-11-06 20:06 UTC (permalink / raw)
  To: dpb; +Cc: git, Paul Mackerras

On Tue, Nov 6, 2018 at 12:03 PM Роман Донченко <dpb@corrigendum.ru> wrote:
>
> 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/20181021163401.4458-1-dummy@example.com/
which was not taken AFAICT.

Thanks,
Stefan

>
> 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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gitk: don't highlight submodule diff lines outside submodule diffs
  2018-11-06 20:06 ` Stefan Beller
@ 2018-11-06 21:56   ` Роман Донченко
  0 siblings, 0 replies; 3+ messages in thread
From: Роман Донченко @ 2018-11-06 21:56 UTC (permalink / raw)
  To: Stefan Beller; +Cc: git, Paul Mackerras

06.11.2018 23:06, Stefan Beller пишет:
> On Tue, Nov 6, 2018 at 12:03 PM Роман Донченко <dpb@corrigendum.ru> wrote:
>>
>> 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/20181021163401.4458-1-dummy@example.com/
> 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

> 
> Thanks,
> Stefan
> 
>>
>> 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
>>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-06 22:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-06 19:54 [PATCH] gitk: don't highlight submodule diff lines outside submodule diffs Роман Донченко
2018-11-06 20:06 ` Stefan Beller
2018-11-06 21:56   ` Роман Донченко

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).