@@ -270,19 +270,6 @@ proc show_other_diff {path w m cont_info} {
270
270
}
271
271
}
272
272
273
- proc get_conflict_marker_size {path} {
274
- set size 7
275
- catch {
276
- set fd_rc [eval [list git_read check-attr " conflict-marker-size" -- $path ]]
277
- set ret [gets $fd_rc line]
278
- close $fd_rc
279
- if {$ret > 0} {
280
- regexp {.*: conflict-marker-size: (\d+)$} $line line size
281
- }
282
- }
283
- return $size
284
- }
285
-
286
273
proc start_show_diff {cont_info {add_opts {}}} {
287
274
global file_states file_lists
288
275
global is_3way_diff is_submodule_diff diff_active repo_config
@@ -298,7 +285,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
298
285
set is_submodule_diff 0
299
286
set diff_active 1
300
287
set current_diff_header {}
301
- set conflict_size [get_conflict_marker_size $path ]
288
+ set conflict_size [gitattr $path conflict-marker-size 7 ]
302
289
303
290
set cmd [list ]
304
291
if {$w eq $ui_index } {
@@ -360,6 +347,10 @@ proc start_show_diff {cont_info {add_opts {}}} {
360
347
}
361
348
362
349
set ::current_diff_inheader 1
350
+ # Detect pre-image lines of the diff3 conflict-style. They are just
351
+ # '++' lines which is not bijective. Thus, we need to maintain a state
352
+ # across lines.
353
+ set ::conflict_in_pre_image 0
363
354
fconfigure $fd \
364
355
-blocking 0 \
365
356
-encoding [get_path_encoding $path ] \
@@ -462,11 +453,23 @@ proc read_diff {fd conflict_size cont_info} {
462
453
{--} {set tags d_--}
463
454
{++} {
464
455
set regexp [string map [list %conflict_size $conflict_size ]\
465
- {^\+\+ ([<>=]){%conflict_size}(?: |$)}]
456
+ {^\+\+ ([<>=| ]){%conflict_size}(?: |$)}]
466
457
if {[regexp $regexp $line _g op]} {
467
458
set is_conflict_diff 1
468
459
set line [string replace $line 0 1 { }]
469
460
set tags d$op
461
+
462
+ # The ||| conflict-marker marks the start of the pre-image.
463
+ # All those lines are also prefixed with '++'. Thus we need
464
+ # to maintain this state.
465
+ set ::conflict_in_pre_image [expr {$op eq {|}}]
466
+ } elseif {$::conflict_in_pre_image } {
467
+ # This is a pre-image line. It is the one which both sides
468
+ # are based on. As it has also the '++' line start, it is
469
+ # normally shown as 'added'. Invert this to '--' to make
470
+ # it a 'removed' line.
471
+ set line [string replace $line 0 1 {--}]
472
+ set tags d_--
470
473
} else {
471
474
set tags d_++
472
475
}
0 commit comments