{"thread":{"id":"20038","subject":"[RFC/PATCH] git-gui: display summary when showing diff of a submodule","startedAt":"2009-07-06T21:31:01Z","lastAt":"2009-07-07T16:45:38Z","messageCount":3,"participants":["Jens Lehmann","Michael J Gruber"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"117514","messageId":"4A526D15.3090202@web.de","threadId":"20038","inReplyTo":null,"subject":"[RFC/PATCH] git-gui: display summary when showing diff of a submodule","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2009-07-06T21:31:01Z","receivedAt":"2009-07-06T21:31:01Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"As it is hard to say what changed in a submodule by looking at the hashes,\nlet's show the colored submodule summary instead.\n\nSigned-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n---\n\nWhile starting to work productively with submodules a few weeks ago i\nnoticed that it is very inconvenient not to know what really changed\nin a submodule when looking at it through git gui in the supermodule.\nSo i wrote this patch as a starting point for a discussion of how a\nsolution might look like.\n\nBasically i would like to see what happened in the submodule between the\ntwo hashes, so it seemed like git submodule summary will provide exactly\nthat information and should be preferred over git diff in that case.\n(I also thought about teaching git diff to provide the information, but\ncame to the conclusion that it would be better to do that in git gui)\n\nAs i don't have that much experience with submodules yet i'm not sure to\nhave taken all corner cases into account ... so a few more eyeballs really\nare appreciated!\n\n git-gui/lib/diff.tcl |   27 +++++++++++++++++++++++++--\n 1 files changed, 25 insertions(+), 2 deletions(-)\n\ndiff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\nindex 925b3f5..67bc49f 100644\n--- a/git-gui/lib/diff.tcl\n+++ b/git-gui/lib/diff.tcl\n@@ -255,7 +255,7 @@ proc show_other_diff {path w m cont_info} {\n\n proc start_show_diff {cont_info {add_opts {}}} {\n \tglobal file_states file_lists\n-\tglobal is_3way_diff diff_active repo_config\n+\tglobal is_3way_diff is_submodule_diff diff_active repo_config\n \tglobal ui_diff ui_index ui_workdir\n \tglobal current_diff_path current_diff_side current_diff_header\n\n@@ -265,6 +265,7 @@ proc start_show_diff {cont_info {add_opts {}}} {\n \tset s $file_states($path)\n \tset m [lindex $s 0]\n \tset is_3way_diff 0\n+\tset is_submodule_diff 0\n \tset diff_active 1\n \tset current_diff_header {}\n\n@@ -295,6 +296,10 @@ proc start_show_diff {cont_info {add_opts {}}} {\n \t\tlappend cmd $path\n \t}\n\n+\tif {[string match {160000 *} [lindex $s 3]]} {\n+\t\tset cmd {submodule summary -- $current_diff_path}\n+\t}\n+\n \tif {[catch {set fd [eval git_read --nice $cmd]} err]} {\n \t\tset diff_active 0\n \t\tunlock_index\n@@ -312,7 +317,7 @@ proc start_show_diff {cont_info {add_opts {}}} {\n }\n\n proc read_diff {fd cont_info} {\n-\tglobal ui_diff diff_active\n+\tglobal ui_diff diff_active is_submodule_diff\n \tglobal is_3way_diff is_conflict_diff current_diff_header\n \tglobal current_diff_queue\n \tglobal diff_empty_count\n@@ -337,6 +342,9 @@ proc read_diff {fd cont_info} {\n \t\t}\n \t\tset ::current_diff_inheader 0\n\n+\t\tif {[regexp {^\\* } $line]} {\n+\t\t\tset is_submodule_diff 1\n+\t\t}\n \t\t# -- Automatically detect if this is a 3 way diff.\n \t\t#\n \t\tif {[string match {@@@ *} $line]} {set is_3way_diff 1}\n@@ -374,6 +382,21 @@ proc read_diff {fd cont_info} {\n \t\t\t\tset tags {}\n \t\t\t}\n \t\t\t}\n+\t\t} elseif {$is_submodule_diff} {\n+\t\t\tif {$line == \"\"} continue\n+\t\t\tif {[regexp {^\\* } $line]} {\n+\t\t\t\tset tags {}\n+\t\t\t} else {\n+\t\t\t\tset op [string range $line 0 2]\n+\t\t\t\tswitch -- $op {\n+\t\t\t\t{  <} {set tags d_+}\n+\t\t\t\t{  >} {set tags d_-}\n+\t\t\t\tdefault {\n+\t\t\t\t\tputs \"error: Unhandled submodule diff marker: {$op}\"\n+\t\t\t\t\tset tags {}\n+\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t}\n \t\t} else {\n \t\t\tset op [string index $line 0]\n \t\t\tswitch -- $op {\n-- \n1.6.3.3.386.g1d0c9.dirty\n"},{"id":"117554","messageId":"4A534728.3050005@drmicha.warpmail.net","threadId":"20038","inReplyTo":"4A526D15.3090202@web.de","subject":"Re: [RFC/PATCH] git-gui: display summary when showing diff of a submodule","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-07-07T13:01:28Z","receivedAt":"2009-07-07T13:01:28Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Jens Lehmann venit, vidit, dixit 06.07.2009 23:31:\n> As it is hard to say what changed in a submodule by looking at the hashes,\n> let's show the colored submodule summary instead.\n> \n\nI can't comment on the patch but I find the goal very valid. I just\nupdated the submodule tutorial wiki to use \"git submodule summary\" in\naddition to plain diff.\n\nMe wonders whether the summary should be the default diff output, or at\nleast a builtin merge driver which can be selected using attributes or such.\n\nMichael\n"},{"id":"117570","messageId":"4A537BB2.90800@web.de","threadId":"20038","inReplyTo":"4A534728.3050005@drmicha.warpmail.net","subject":"Re: [RFC/PATCH] git-gui: display summary when showing diff of a submodule","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2009-07-07T16:45:38Z","receivedAt":"2009-07-07T16:45:38Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Michael J Gruber schrieb:\n> Me wonders whether the summary should be the default diff output, or at\n> least a builtin merge driver which can be selected using attributes or such.\n\nYes, i was thinking about that too. But i have no idea if it would be\na good or bad idea to extend git diff that way.\n\nAnd for git gui it doesn't really matter. The only difference to my patch\nwould be the line where the diff command is replaced with submodule summary\n(assuming the output would stay compatible). The rest of the patch is about\nhandling that output, no matter how it is generated.\n\n\nJens\n"}]}