All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gitk: Use the --submodule option for diffs
@ 2009-10-27 14:59 Jens Lehmann
  2009-10-27 15:41 ` Johannes Schindelin
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jens Lehmann @ 2009-10-27 14:59 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Junio C Hamano, Git Mailing List

Instead of just showing not-quite-helpful SHA-1 pairs display the first
lines of the corresponding commit messages in the submodule (similar to
the output of 'git submodule summary').

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---

This patch applies to 'next' and uses the new --submodule option of git
diff to achieve a more meaningful output of submodule differences in
gitk.

Any objections against making this the default?

(for those interested: a version of git gui with similar functionality
is available in 'master' of Shawn's repo but not yet merged).


 gitk-git/gitk |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index a0214b7..5e2572d 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -7207,7 +7207,7 @@ proc diffcmd {ids flags} {
     if {$i >= 0} {
 	if {[llength $ids] > 1 && $j < 0} {
 	    # comparing working directory with some specific revision
-	    set cmd [concat | git diff-index $flags]
+	    set cmd [concat | git diff-index --submodule $flags]
 	    if {$i == 0} {
 		lappend cmd -R [lindex $ids 1]
 	    } else {
@@ -7215,13 +7215,13 @@ proc diffcmd {ids flags} {
 	    }
 	} else {
 	    # comparing working directory with index
-	    set cmd [concat | git diff-files $flags]
+	    set cmd [concat | git diff-files --submodule $flags]
 	    if {$j == 1} {
 		lappend cmd -R
 	    }
 	}
     } elseif {$j >= 0} {
-	set cmd [concat | git diff-index --cached $flags]
+	set cmd [concat | git diff-index --cached --submodule $flags]
 	if {[llength $ids] > 1} {
 	    # comparing index with specific revision
 	    if {$i == 0} {
@@ -7234,7 +7234,7 @@ proc diffcmd {ids flags} {
 	    lappend cmd HEAD
 	}
     } else {
-	set cmd [concat | git diff-tree -r $flags $ids]
+	set cmd [concat | git diff-tree -r --submodule $flags $ids]
     }
     return $cmd
 }
@@ -7481,6 +7481,21 @@ proc getblobdiffline {bdf ids} {
 	    set diffnparents [expr {[string length $ats] - 1}]
 	    set diffinhdr 0

+	} elseif {![string compare -length 10 "Submodule " $line]} {
+	    # start of a new submodule
+	    if {[string compare [$ctext get "end - 4c" end] "\n \n\n"]} {
+		$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
+	} elseif {![string compare -length 3 "  >" $line]} {
+	    $ctext insert end "$line\n" dresult
+	} elseif {![string compare -length 3 "  <" $line]} {
+	    $ctext insert end "$line\n" d0
 	} elseif {$diffinhdr} {
 	    if {![string compare -length 12 "rename from " $line]} {
 		set fname [string range $line [expr 6 + [string first " from " $line] ] end]
-- 
1.6.5.2.182.g338ab.dirty

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

* Re: [PATCH] gitk: Use the --submodule option for diffs
  2009-10-27 14:59 [PATCH] gitk: Use the --submodule option for diffs Jens Lehmann
@ 2009-10-27 15:41 ` Johannes Schindelin
  2009-10-28  4:03 ` Paul Mackerras
  2009-10-28  7:19 ` [PATCH] gitk: Use the --submodule option for diffs Junio C Hamano
  2 siblings, 0 replies; 6+ messages in thread
From: Johannes Schindelin @ 2009-10-27 15:41 UTC (permalink / raw)
  To: Jens Lehmann; +Cc: Paul Mackerras, Junio C Hamano, Git Mailing List

Hi,

On Tue, 27 Oct 2009, Jens Lehmann wrote:

> Instead of just showing not-quite-helpful SHA-1 pairs display the first
> lines of the corresponding commit messages in the submodule (similar to
> the output of 'git submodule summary').
> 
> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
> ---
> 
> This patch applies to 'next' and uses the new --submodule option of git
> diff to achieve a more meaningful output of submodule differences in
> gitk.
> 
> Any objections against making this the default?

Certainly not from me.  It would help people in my day-job project.

Ciao,
Dscho

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

* Re: [PATCH] gitk: Use the --submodule option for diffs
  2009-10-27 14:59 [PATCH] gitk: Use the --submodule option for diffs Jens Lehmann
  2009-10-27 15:41 ` Johannes Schindelin
@ 2009-10-28  4:03 ` Paul Mackerras
  2009-10-28 11:40   ` [PATCH v2] gitk: Use the --submodule option for displaying diffs when available Jens Lehmann
  2009-10-28  7:19 ` [PATCH] gitk: Use the --submodule option for diffs Junio C Hamano
  2 siblings, 1 reply; 6+ messages in thread
From: Paul Mackerras @ 2009-10-28  4:03 UTC (permalink / raw)
  To: Jens Lehmann; +Cc: Junio C Hamano, Git Mailing List

Jens Lehmann writes:

> Instead of just showing not-quite-helpful SHA-1 pairs display the first
> lines of the corresponding commit messages in the submodule (similar to
> the output of 'git submodule summary').
> 
> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
> ---
> 
> This patch applies to 'next' and uses the new --submodule option of git
> diff to achieve a more meaningful output of submodule differences in
> gitk.

(That sentence should have been in the commit message.)

> Any objections against making this the default?

What version of git is the first to have the --submodule option?
Since it's a new option we should make gitk use it only if the
underlying git is new enough, like we do with the --textconv option.

Also, the commit message is a bit sparse; it doesn't mention that this
affects the diff display, for instance.

Paul.

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

* Re: [PATCH] gitk: Use the --submodule option for diffs
  2009-10-27 14:59 [PATCH] gitk: Use the --submodule option for diffs Jens Lehmann
  2009-10-27 15:41 ` Johannes Schindelin
  2009-10-28  4:03 ` Paul Mackerras
@ 2009-10-28  7:19 ` Junio C Hamano
  2 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2009-10-28  7:19 UTC (permalink / raw)
  To: Jens Lehmann; +Cc: Paul Mackerras, Junio C Hamano, Git Mailing List

Jens Lehmann <Jens.Lehmann@web.de> writes:

> Instead of just showing not-quite-helpful SHA-1 pairs display the first
> lines of the corresponding commit messages in the submodule (similar to
> the output of 'git submodule summary').
>
> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
> ---
>
> This patch applies to 'next' and uses the new --submodule option of git
> diff to achieve a more meaningful output of submodule differences in
> gitk.
>
> Any objections against making this the default?

It looks like you are not making this the default, but are making it
mandatory.  That's quite different.

As long as gitk ships with matching version of git, I do not think it is a
huge problem to force "diff" to always run with --submodule option, but if
that is what the patch does, I'd prefer to see the patch says so, instead
of giving a false impression that there may be a way to disable it if one
wants to.

Looking at the patched text, I had to wonder where these $flags come from.
The callers of "diffcmd" give it to you, and I am not sure if all of them
want -p format diffs.  Specifically, what does gettreediffs do?  Does it
make sense to give --submodule to that invocation?

Yes, I know --submodule happens to be a no-op in non-patch format diffs,
but I do not think that is by design.  It is something somebody may notice
and correct it later, at which time this patch will be broken.

I also suspect that this might break getpatchid, but as long as all the
patches consistently change/break ids it would be Ok.

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

* [PATCH v2] gitk: Use the --submodule option for displaying diffs when available
  2009-10-28  4:03 ` Paul Mackerras
@ 2009-10-28 11:40   ` Jens Lehmann
  2009-11-03 11:32     ` Paul Mackerras
  0 siblings, 1 reply; 6+ messages in thread
From: Jens Lehmann @ 2009-10-28 11:40 UTC (permalink / raw)
  To: Paul Mackerras, Junio C Hamano; +Cc: Git Mailing List

Instead of just showing not-quite-helpful SHA-1 pairs in the diff display
of a submodule gitk will display the first lines of the corresponding
commit messages (similar to the output of 'git submodule summary') when
the underlying git installation supports this. That makes it much easier
to evaluate the changes, as it eliminates the need to start a gitk inside
the submodule and use the superprojects hashes there to find out what the
commits are about.

This patch applies to 'next' - which will be 1.6.6 or 1.7.0 when merged -
and uses the new --submodule option of git diff when a version of 1.6.6 or
higher is detected to achieve a more human readable output of submodule
differences in gitk.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---


Thanks for the review of the first version of this patch. I tried to
address all the issues raised and moved the additions of the --submodule
flag to the getblobdiffs procedure, where the --textconv flag is handled
too.


 gitk-git/gitk |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index a0214b7..b06cac7 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -7343,7 +7343,11 @@ proc getblobdiffs {ids} {
     if {[package vcompare $git_version "1.6.1"] >= 0} {
 	set textconv "--textconv"
     }
-    set cmd [diffcmd $ids "-p $textconv -C --cc --no-commit-id -U$diffcontext"]
+    set submodule {}
+    if {[package vcompare $git_version "1.6.6"] >= 0} {
+	set submodule "--submodule"
+    }
+    set cmd [diffcmd $ids "-p $textconv $submodule  -C --cc --no-commit-id -U$diffcontext"]
     if {$ignorespace} {
 	append cmd " -w"
     }
@@ -7481,6 +7485,21 @@ proc getblobdiffline {bdf ids} {
 	    set diffnparents [expr {[string length $ats] - 1}]
 	    set diffinhdr 0

+	} elseif {![string compare -length 10 "Submodule " $line]} {
+	    # start of a new submodule
+	    if {[string compare [$ctext get "end - 4c" end] "\n \n\n"]} {
+		$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
+	} elseif {![string compare -length 3 "  >" $line]} {
+	    $ctext insert end "$line\n" dresult
+	} elseif {![string compare -length 3 "  <" $line]} {
+	    $ctext insert end "$line\n" d0
 	} elseif {$diffinhdr} {
 	    if {![string compare -length 12 "rename from " $line]} {
 		set fname [string range $line [expr 6 + [string first " from " $line] ] end]
-- 
1.6.5.2.182.g3d976.dirty

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

* Re: [PATCH v2] gitk: Use the --submodule option for displaying diffs when available
  2009-10-28 11:40   ` [PATCH v2] gitk: Use the --submodule option for displaying diffs when available Jens Lehmann
@ 2009-11-03 11:32     ` Paul Mackerras
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Mackerras @ 2009-11-03 11:32 UTC (permalink / raw)
  To: Jens Lehmann; +Cc: Junio C Hamano, Git Mailing List

Jens Lehmann writes:

> Instead of just showing not-quite-helpful SHA-1 pairs in the diff display
> of a submodule gitk will display the first lines of the corresponding
> commit messages (similar to the output of 'git submodule summary') when
> the underlying git installation supports this. That makes it much easier
> to evaluate the changes, as it eliminates the need to start a gitk inside
> the submodule and use the superprojects hashes there to find out what the
> commits are about.
> 
> This patch applies to 'next' - which will be 1.6.6 or 1.7.0 when merged -
> and uses the new --submodule option of git diff when a version of 1.6.6 or
> higher is detected to achieve a more human readable output of submodule
> differences in gitk.
> 
> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>

Thanks, applied.

Paul.

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

end of thread, other threads:[~2009-11-03 11:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-27 14:59 [PATCH] gitk: Use the --submodule option for diffs Jens Lehmann
2009-10-27 15:41 ` Johannes Schindelin
2009-10-28  4:03 ` Paul Mackerras
2009-10-28 11:40   ` [PATCH v2] gitk: Use the --submodule option for displaying diffs when available Jens Lehmann
2009-11-03 11:32     ` Paul Mackerras
2009-10-28  7:19 ` [PATCH] gitk: Use the --submodule option for diffs Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.