{"thread":{"id":"22225","subject":"[PATCH RESEND2] git gui: Use git diff --submodule when available","startedAt":"2010-01-14T22:41:51Z","lastAt":"2010-01-14T22:41:51Z","messageCount":1,"participants":["Jens Lehmann"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"131684","messageId":"4B4F9DAF.30909@web.de","threadId":"22225","inReplyTo":null,"subject":"[PATCH RESEND2] git gui: Use git diff --submodule when available","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2010-01-14T22:41:51Z","receivedAt":"2010-01-14T22:41:51Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Changed the use of submodule summary to diff --submodule because the\nimplementation in C is much faster than the submodule script. Also a test\nhas been added to make sure that the underlying git supports the diff\noption --submodule (which was introduced in 1.6.6).\n\nSigned-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n---\n\nDid not hear anything about my last resend on December 28th, so i try\nagain.\n\nTo explain what i mean by \"much faster\", here are the numbers (best of\nthree) for a small repo with a changed submodule (git checkout HEAD^)\nunder Linux:\n\n\ntime git submodule summary\n<snip>\n\nreal\t0m0.219s\nuser\t0m0.050s\nsys\t0m0.111s\n\n\ntime git diff --submodule\n<snip>\n\nreal\t0m0.012s\nuser\t0m0.003s\nsys\t0m0.009s\n\n\nIn my experience this patch changes the user experience from\n\"a noticeable delay\" to \"instantaneous\".\n\n\n git-gui/lib/diff.tcl |   21 +++++++++------------\n 1 files changed, 9 insertions(+), 12 deletions(-)\n\ndiff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\nindex bd5d189..0623e3e 100644\n--- a/git-gui/lib/diff.tcl\n+++ b/git-gui/lib/diff.tcl\n@@ -281,6 +281,14 @@ proc start_show_diff {cont_info {add_opts {}}} {\n \t\t}\n \t}\n\n+\tif {[git-version >= \"1.6.6\"]} {\n+\t\tif {[string match {160000 *} [lindex $s 2]]\n+\t\t    || [string match {160000 *} [lindex $s 3]]} {\n+\t\t\tset is_submodule_diff 1\n+\t\t\tlappend cmd --submodule\n+\t\t}\n+\t}\n+\n \tlappend cmd -p\n \tlappend cmd --no-color\n \tif {$repo_config(gui.diffcontext) >= 1} {\n@@ -296,16 +304,6 @@ proc start_show_diff {cont_info {add_opts {}}} {\n \t\tlappend cmd $path\n \t}\n\n-\tif {[string match {160000 *} [lindex $s 2]]\n-        || [string match {160000 *} [lindex $s 3]]} {\n-\t\tset is_submodule_diff 1\n-\t\tif {$w eq $ui_index} {\n-\t\t\tset cmd [list submodule summary --cached -- $path]\n-\t\t} else {\n-\t\t\tset cmd [list submodule summary --files -- $path]\n-\t\t}\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@@ -387,8 +385,7 @@ proc read_diff {fd cont_info} {\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 line [string replace $line 0 1 {Submodule }]\n+\t\t\tif {[regexp {^Submodule } $line]} {\n \t\t\t\tset tags d_@\n \t\t\t} else {\n \t\t\t\tset op [string range $line 0 2]\n-- \n1.6.6.rc2.274.g2cee7\n"}]}