diff options
author | Jens Lehmann <Jens.Lehmann@web.de> | 2009-07-21 19:32:31 +0200 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2009-08-10 08:30:26 -0700 |
commit | 246295bdeb00ec6d533f22937992d1f9a06f8e71 (patch) | |
tree | 124aebb879a03a806437e3bfae804579e5e66570 | |
parent | git-gui: Fixes for Mac OS X TkAqua (diff) | |
download | tgif-246295bdeb00ec6d533f22937992d1f9a06f8e71.tar.xz |
git-gui: display summary when showing diff of a submodule
As it is hard to say what changed in a submodule by looking at the hashes,
let's show the colored submodule summary instead.
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rwxr-xr-x | git-gui.sh | 2 | ||||
-rw-r--r-- | lib/diff.tcl | 30 |
2 files changed, 29 insertions, 3 deletions
diff --git a/git-gui.sh b/git-gui.sh index 14b92ba786..3c0ce26029 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -3212,7 +3212,7 @@ proc popup_diff_menu {ctxm ctxmmg x y X Y} { set l [mc "Stage Hunk For Commit"] set t [mc "Stage Line For Commit"] } - if {$::is_3way_diff + if {$::is_3way_diff || $::is_submodule_diff || $current_diff_path eq {} || {__} eq $state || {_O} eq $state diff --git a/lib/diff.tcl b/lib/diff.tcl index 925b3f56c1..ae1ea3a615 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -255,7 +255,7 @@ proc show_other_diff {path w m cont_info} { proc start_show_diff {cont_info {add_opts {}}} { global file_states file_lists - global is_3way_diff diff_active repo_config + global is_3way_diff is_submodule_diff diff_active repo_config global ui_diff ui_index ui_workdir global current_diff_path current_diff_side current_diff_header @@ -265,6 +265,7 @@ proc start_show_diff {cont_info {add_opts {}}} { set s $file_states($path) set m [lindex $s 0] set is_3way_diff 0 + set is_submodule_diff 0 set diff_active 1 set current_diff_header {} @@ -295,6 +296,11 @@ proc start_show_diff {cont_info {add_opts {}}} { lappend cmd $path } + if {[string match {160000 *} [lindex $s 2]] + || [string match {160000 *} [lindex $s 3]]} { + set cmd {submodule summary -- $current_diff_path} + } + if {[catch {set fd [eval git_read --nice $cmd]} err]} { set diff_active 0 unlock_index @@ -312,7 +318,7 @@ proc start_show_diff {cont_info {add_opts {}}} { } proc read_diff {fd cont_info} { - global ui_diff diff_active + global ui_diff diff_active is_submodule_diff global is_3way_diff is_conflict_diff current_diff_header global current_diff_queue global diff_empty_count @@ -337,6 +343,9 @@ proc read_diff {fd cont_info} { } set ::current_diff_inheader 0 + if {[regexp {^\* } $line]} { + set is_submodule_diff 1 + } # -- Automatically detect if this is a 3 way diff. # if {[string match {@@@ *} $line]} {set is_3way_diff 1} @@ -374,6 +383,23 @@ proc read_diff {fd cont_info} { set tags {} } } + } elseif {$is_submodule_diff} { + if {$line == ""} continue + if {[regexp {^\* } $line]} { + set line [string replace $line 0 1 {Submodule }] + set tags d_@ + } else { + set op [string range $line 0 2] + switch -- $op { + { <} {set tags d_-} + { >} {set tags d_+} + { W} {set tags {}} + default { + puts "error: Unhandled submodule diff marker: {$op}" + set tags {} + } + } + } } else { set op [string index $line 0] switch -- $op { |