git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Lehmann <Jens.Lehmann@web.de>
To: Thomas Rast <trast@student.ethz.ch>
Cc: git@vger.kernel.org,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Eelis van der Weegen <eelis@eelis.net>,
	Junio C Hamano <gitster@pobox.com>,
	Paul Mackerras <paulus@samba.org>, Miles Bader <miles@gnu.org>
Subject: Re: [PATCH v4 2/3] gitk: do not parse "  >" context as submodule change
Date: Thu, 15 Apr 2010 21:57:22 +0200	[thread overview]
Message-ID: <4BC76FA2.3030204@web.de> (raw)
In-Reply-To: <5531510bfb94997f729a894a0b5a3158177a9add.1271260308.git.trast@student.ethz.ch>

Am 14.04.2010 17:59, schrieb Thomas Rast:
> Since 5c838d2 (gitk: Use the --submodule option for displaying diffs
> when available, 2009-10-28) gitk erroneously matches "  >" and "  <"
> at the beginning of a line in the submodule code even if we're in the
> diff text section and the lines should be treated as context.
> 
> Fix by (ab)using the $diffinhdr variable also in the 'Submodule...'
> case, and move the "  >"/"  <" specific code inside the $diffinhdr
> test.  The existing code will set $diffinhdr to 0 when it hits a
> "+++", so that it is always 0 when we can hit a context line.

Thanks for fixing this issue I accidentally introduced!

In that said patch I unfortunately also managed to screw up the
submodule name detection when it was not followed just by commits
(but e.g. by "contains untracked content"). I did already send a
patch to address this issue, but here is a rebased version on top
of your patch series just in case:

--------------------8<--------------------
From: Jens Lehmann <Jens.Lehmann@web.de>
Date: Thu, 15 Apr 2010 21:53:12 +0200
Subject: [PATCH] Teach gitk to display dirty submodules correctly

Since 1.7.1 "git diff --submodule" prints out extra lines when the
submodule contains untracked or modified files. Show all those lines for
one submodule under the same header.

Also e.g. for newly added or removed submodules the submodule name
contained trailing garbage because the extraction of the name was not
done right. Now it scans either for the first hex number followed by a
".." or the string "contains ".

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---
 gitk-git/gitk |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index f2a1eb7..93d25ec 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -7530,7 +7530,7 @@ proc getblobdiffs {ids} {
     global worddiff
     global limitdiffs vfilelimit curview
     global diffencoding targetline diffnparents
-    global git_version
+    global git_version currdiffsubmod

     set textconv {}
     if {[package vcompare $git_version "1.6.1"] >= 0} {
@@ -7560,6 +7560,7 @@ proc getblobdiffs {ids} {
     set diffencoding [get_path_encoding {}]
     fconfigure $bdf -blocking 0 -encoding binary -eofchar {}
     set blobdifffd($ids) $bdf
+    set currdiffsubmod ""
     filerun $bdf [list getblobdiffline $bdf $diffids]
 }

@@ -7631,7 +7632,7 @@ proc getblobdiffline {bdf ids} {
     global ctext_file_names ctext_file_lines
     global diffinhdr treediffs mergemax diffnparents
     global diffencoding jump_to_here targetline diffline
-    global worddiff
+    global worddiff currdiffsubmod

     set nr 0
     $ctext conf -state normal
@@ -7712,15 +7713,24 @@ proc getblobdiffline {bdf ids} {

 	} elseif {![string compare -length 10 "Submodule " $line]} {
 	    # start of a new submodule
-	    if {[string compare [$ctext get "end - 4c" end] "\n \n\n"]} {
+	    if {[regexp -indices "\[0-9a-f\]+\\.\\." $line nameend]} {
+		set fname [string range $line 10 [expr [lindex $nameend 0] - 2]]
+	    } else {
+		set fname [string range $line 10 [expr [string first "contains " $line] - 2]]
+	    }
+	    if {$currdiffsubmod != $fname} {
 		$ctext insert end "\n";     # Add newline after commit message
 	    }
 	    set curdiffstart [$ctext index "end - 1c"]
 	    lappend ctext_file_names ""
-	    set fname [string range $line 10 [expr [string last " " $line] - 1]]
-	    lappend ctext_file_lines $fname
-	    makediffhdr $fname $ids
-	    $ctext insert end "\n$line\n" filesep
+	    if {$currdiffsubmod != $fname} {
+		lappend ctext_file_lines $fname
+		makediffhdr $fname $ids
+		set currdiffsubmod $fname
+		$ctext insert end "\n$line\n" filesep
+	    } else {
+		$ctext insert end "$line\n" filesep
+	    }
 	    # pretend we're in a file header to correctly parse "  [><]"
 	    set diffinhdr 1
 	} elseif {$diffinhdr} {
@@ -8588,7 +8598,7 @@ proc do_cmp_commits {a b} {
 }

 proc diffcommits {a b} {
-    global diffcontext diffids blobdifffd diffinhdr
+    global diffcontext diffids blobdifffd diffinhdr currdiffsubmod

     set tmpdir [gitknewtmpdir]
     set fna [file join $tmpdir "commit-[string range $a 0 7]"]
@@ -8609,6 +8619,7 @@ proc diffcommits {a b} {
     set diffids [list commits $a $b]
     set blobdifffd($diffids) $fd
     set diffinhdr 0
+    set currdiffsubmod ""
     filerun $fd [list getblobdiffline $fd $diffids]
 }

-- 
1.7.1.rc1.252.gff9f

  reply	other threads:[~2010-04-15 19:57 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1269996525.git.trast@student.ethz>
2010-04-04 13:46 ` [PATCH 0/2] gitk --color-words Thomas Rast
2010-04-04 13:46   ` [PATCH 1/2] diff: add --word-diff option that generalizes --color-words Thomas Rast
2010-04-05  2:06     ` Junio C Hamano
2010-04-05 10:20       ` Thomas Rast
2010-04-05 18:46         ` Junio C Hamano
2010-04-05 18:53           ` Miles Bader
2010-04-12 13:07             ` [PATCH v3 0/2] gitk --color-words Thomas Rast
2010-04-12 13:07               ` [PATCH v3 1/3] diff: add --word-diff option that generalizes --color-words Thomas Rast
2010-04-12 16:31                 ` Junio C Hamano
2010-04-13  9:27                   ` Thomas Rast
2010-04-14 15:59                   ` [PATCH v4 0/3] git-diff --word-diff/gitk --color-words Thomas Rast
2010-04-14 15:59                     ` [PATCH v4 1/3] diff: add --word-diff option that generalizes --color-words Thomas Rast
2010-04-14 21:23                       ` Junio C Hamano
2010-04-14 15:59                     ` [PATCH v4 2/3] gitk: do not parse " >" context as submodule change Thomas Rast
2010-04-15 19:57                       ` Jens Lehmann [this message]
2010-04-17  6:33                       ` Paul Mackerras
2010-04-17 12:20                         ` Thomas Rast
2010-04-19  1:08                           ` Paul Mackerras
2010-04-19 16:27                             ` [PATCH v4' 1/2] " Thomas Rast
2010-04-19 16:27                               ` [PATCH v4' 2/2] gitk: add the equivalent of diff --color-words Thomas Rast
2010-04-19 17:22                               ` [PATCH v4' 1/2] gitk: do not parse " >" context as submodule change Jens Lehmann
2010-04-20 17:05                                 ` Jens Lehmann
2010-04-14 15:59                     ` [PATCH v4 3/3] gitk: add the equivalent of diff --color-words Thomas Rast
2010-04-17  6:35                       ` Paul Mackerras
2010-04-17  6:55                         ` Junio C Hamano
2010-04-12 13:07               ` [PATCH v3 2/3] gitk: do not parse " >" context as submodule change Thomas Rast
2010-04-12 13:25                 ` [PATCH v3.1] " Thomas Rast
2010-04-12 13:07               ` [PATCH v3 3/3] gitk: add the equivalent of diff --color-words Thomas Rast
2010-04-06  9:20           ` [PATCH 1/2] diff: add --word-diff option that generalizes --color-words Thomas Rast
2010-04-04 13:46   ` [PATCH 2/2] gitk: add the equivalent of diff --color-words Thomas Rast

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=4BC76FA2.3030204@web.de \
    --to=jens.lehmann@web.de \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=eelis@eelis.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=miles@gnu.org \
    --cc=paulus@samba.org \
    --cc=trast@student.ethz.ch \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).