@@ -255,7 +255,7 @@ proc show_other_diff {path w m cont_info} {
255
255
256
256
proc start_show_diff {cont_info {add_opts {}}} {
257
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
259
global ui_diff ui_index ui_workdir
260
260
global current_diff_path current_diff_side current_diff_header
261
261
@@ -265,6 +265,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
265
265
set s $file_states($path)
266
266
set m [lindex $s 0]
267
267
set is_3way_diff 0
268
+ set is_submodule_diff 0
268
269
set diff_active 1
269
270
set current_diff_header {}
270
271
@@ -295,6 +296,11 @@ proc start_show_diff {cont_info {add_opts {}}} {
295
296
lappend cmd $path
296
297
}
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
+
298
304
if {[catch {set fd [eval git_read --nice $cmd ]} err]} {
299
305
set diff_active 0
300
306
unlock_index
@@ -312,7 +318,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
312
318
}
313
319
314
320
proc read_diff {fd cont_info} {
315
- global ui_diff diff_active
321
+ global ui_diff diff_active is_submodule_diff
316
322
global is_3way_diff is_conflict_diff current_diff_header
317
323
global current_diff_queue
318
324
global diff_empty_count
@@ -337,6 +343,9 @@ proc read_diff {fd cont_info} {
337
343
}
338
344
set ::current_diff_inheader 0
339
345
346
+ if {[regexp {^\* } $line ]} {
347
+ set is_submodule_diff 1
348
+ }
340
349
# -- Automatically detect if this is a 3 way diff.
341
350
#
342
351
if {[string match {@@@ *} $line ]} {set is_3way_diff 1}
@@ -374,6 +383,23 @@ proc read_diff {fd cont_info} {
374
383
set tags {}
375
384
}
376
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
+ }
377
403
} else {
378
404
set op [string index $line 0]
379
405
switch -- $op {
0 commit comments