git-gui: Use git diff --submodule when available
Doing so is much faster and gives the same output. Here are some numbers: $ time git submodule summary real 0m0.219s user 0m0.050s sys 0m0.111s $ time git diff --submodule real 0m0.012s user 0m0.003s sys 0m0.009s Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Jens Lehmann committed
Jan 23, 2010 at 23:04 UTC
a9ae14a1c50a9b5bd051be629dba0fb04b6fd67a
1 file changed
+13
-4
lib/diff.tcl
+13
-4
@@ -281,6 +281,15 @@ proc start_show_diff {cont_info {add_opts {}}} {
281
}
282
}
283
284
+ if {[string match {160000 *} [lindex $s 2]]
285
+ || [string match {160000 *} [lindex $s 3]]} {
286
+ set is_submodule_diff 1
287
+
288
+ if {[git-version >= "1.6.6"]} {
289
+ lappend cmd --submodule
290
+ }
291
+ }
292
+
293
lappend cmd -p
294
lappend cmd --no-color
295
if {$repo_config(gui.diffcontext) >= 1} {
@@ -296,9 +305,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
305
lappend cmd $path
306
}
307
299
- if {[string match {160000 *} [lindex $s 2]]
300
- || [string match {160000 *} [lindex $s 3]]} {
301
- set is_submodule_diff 1
308
+ if {$is_submodule_diff && [git-version < "1.6.6"]} {
309
if {$w eq $ui_index} {
310
set cmd [list submodule summary --cached -- $path]
311
} else {
@@ -387,7 +394,9 @@ proc read_diff {fd cont_info} {
394
}
395
} elseif {$is_submodule_diff} {
396
if {$line == ""} continue
390
- if {[regexp {^\* } $line]} {
397
+ if {[regexp {^Submodule } $line]} {
398
+ set tags d_@
399
+ } elseif {[regexp {^\* } $line]} {
400
set line [string replace $line 0 1 {Submodule }]
401
set tags d_@
402
} else {