Git Mailing List Archive on lore.kernel.org
 help / color / Atom feed
From: "Роман Донченко" <dpb@corrigendum.ru>
To: paulus@ozlabs.org
Cc: git@vger.kernel.org, "Роман Донченко" <dpb@corrigendum.ru>
Subject: [PATCH] gitk: don't highlight files after submodules as submodules
Date: Sat,  2 Nov 2019 02:34:27 +0300
Message-ID: <20191101233427.4108-1-dpb@corrigendum.ru> (raw)

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>
---
 gitk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gitk b/gitk
index abe4805..7c425d2 100755
--- a/gitk
+++ b/gitk
@@ -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} {
-- 
2.19.1.windows.1


             reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-01 23:34 Роман Донченко [this message]
2019-12-15  4:39 ` Paul Mackerras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191101233427.4108-1-dpb@corrigendum.ru \
    --to=dpb@corrigendum.ru \
    --cc=git@vger.kernel.org \
    --cc=paulus@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Mailing List Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/git/0 git/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 git git/ https://lore.kernel.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.git


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git