Skip to content

Commit af413de

Browse files
jlehmannspearce
authored andcommitted
git-gui: fix diff for partially staged submodule changes
When a submodule commit had already been staged and another commit had been checked out inside the submodule, the diff always displayed the submodule commit log messages between the last supermodule commit and the working tree, totally ignoring the commit in the index. Signed-off-by: Jens Lehmann <[email protected]> Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent b350e46 commit af413de

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/diff.tcl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,12 @@ proc start_show_diff {cont_info {add_opts {}}} {
298298

299299
if {[string match {160000 *} [lindex $s 2]]
300300
|| [string match {160000 *} [lindex $s 3]]} {
301-
set cmd {submodule summary -- $current_diff_path}
301+
set is_submodule_diff 1
302+
if {$w eq $ui_index} {
303+
set cmd {submodule summary --cached -- $current_diff_path}
304+
} else {
305+
set cmd {submodule summary --files -- $current_diff_path}
306+
}
302307
}
303308

304309
if {[catch {set fd [eval git_read --nice $cmd]} err]} {
@@ -343,9 +348,6 @@ proc read_diff {fd cont_info} {
343348
}
344349
set ::current_diff_inheader 0
345350

346-
if {[regexp {^\* } $line]} {
347-
set is_submodule_diff 1
348-
}
349351
# -- Automatically detect if this is a 3 way diff.
350352
#
351353
if {[string match {@@@ *} $line]} {set is_3way_diff 1}

0 commit comments

Comments
 (0)