Skip to content

Commit a9ae14a

Browse files
jlehmannspearce
authored andcommitted
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 <[email protected]> Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent 87cd09f commit a9ae14a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

lib/diff.tcl

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,15 @@ proc start_show_diff {cont_info {add_opts {}}} {
281281
}
282282
}
283283

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+
284293
lappend cmd -p
285294
lappend cmd --no-color
286295
if {$repo_config(gui.diffcontext) >= 1} {
@@ -296,9 +305,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
296305
lappend cmd $path
297306
}
298307

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"]} {
302309
if {$w eq $ui_index} {
303310
set cmd [list submodule summary --cached -- $path]
304311
} else {
@@ -387,7 +394,9 @@ proc read_diff {fd cont_info} {
387394
}
388395
} elseif {$is_submodule_diff} {
389396
if {$line == ""} continue
390-
if {[regexp {^\* } $line]} {
397+
if {[regexp {^Submodule } $line]} {
398+
set tags d_@
399+
} elseif {[regexp {^\* } $line]} {
391400
set line [string replace $line 0 1 {Submodule }]
392401
set tags d_@
393402
} else {

0 commit comments

Comments
 (0)