@matheusbsbs / matheus-bagliano / commits / 246295bdeb
Fork 0

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>

Jens Lehmann committed Jul 21, 2009 at 19:32 UTC 246295bdeb00ec6d533f22937992d1f9a06f8e71
2 files changed +29 -3
git-gui.sh
+1 -1
@@ -3212,7 +3212,7 @@ proc popup_diff_menu {ctxm ctxmmg x y X Y} {
3212 set l [mc "Stage Hunk For Commit"]
3213 set t [mc "Stage Line For Commit"]
3214 }
3215 - if {$::is_3way_diff
3215 + if {$::is_3way_diff || $::is_submodule_diff
3216 || $current_diff_path eq {}
3217 || {__} eq $state
3218 || {_O} eq $state
lib/diff.tcl
+28 -2
@@ -255,7 +255,7 @@ proc show_other_diff {path w m cont_info} {
255
256 proc start_show_diff {cont_info {add_opts {}}} {
257 global file_states file_lists
258 - global is_3way_diff diff_active repo_config
258 + global is_3way_diff is_submodule_diff diff_active repo_config
259 global ui_diff ui_index ui_workdir
260 global current_diff_path current_diff_side current_diff_header
261
@@ -265,6 +265,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
265 set s $file_states($path)
266 set m [lindex $s 0]
267 set is_3way_diff 0
268 + set is_submodule_diff 0
269 set diff_active 1
270 set current_diff_header {}
271
@@ -295,6 +296,11 @@ proc start_show_diff {cont_info {add_opts {}}} {
296 lappend cmd $path
297 }
298
299 + if {[string match {160000 *} [lindex $s 2]]
300 + || [string match {160000 *} [lindex $s 3]]} {
301 + set cmd {submodule summary -- $current_diff_path}
302 + }
303 +
304 if {[catch {set fd [eval git_read --nice $cmd]} err]} {
305 set diff_active 0
306 unlock_index
@@ -312,7 +318,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
318 }
319
320 proc read_diff {fd cont_info} {
315 - global ui_diff diff_active
321 + global ui_diff diff_active is_submodule_diff
322 global is_3way_diff is_conflict_diff current_diff_header
323 global current_diff_queue
324 global diff_empty_count
@@ -337,6 +343,9 @@ proc read_diff {fd cont_info} {
343 }
344 set ::current_diff_inheader 0
345
346 + if {[regexp {^\* } $line]} {
347 + set is_submodule_diff 1
348 + }
349 # -- Automatically detect if this is a 3 way diff.
350 #
351 if {[string match {@@@ *} $line]} {set is_3way_diff 1}
@@ -374,6 +383,23 @@ proc read_diff {fd cont_info} {
383 set tags {}
384 }
385 }
386 + } elseif {$is_submodule_diff} {
387 + if {$line == ""} continue
388 + if {[regexp {^\* } $line]} {
389 + set line [string replace $line 0 1 {Submodule }]
390 + set tags d_@
391 + } else {
392 + set op [string range $line 0 2]
393 + switch -- $op {
394 + { <} {set tags d_-}
395 + { >} {set tags d_+}
396 + { W} {set tags {}}
397 + default {
398 + puts "error: Unhandled submodule diff marker: {$op}"
399 + set tags {}
400 + }
401 + }
402 + }
403 } else {
404 set op [string index $line 0]
405 switch -- $op {