summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBert Wesarg <bert.wesarg@googlemail.com>2019-10-02 07:36:02 (GMT)
committerPratyush Yadav <me@yadavpratyush.com>2019-10-03 21:56:15 (GMT)
commitb436825b9bf3c606bb684e41f426fa3d0c088328 (patch)
treec84247bc84f729e0e84e19fbb874971b1162ee3b /lib
parentc3b57dc2a0fe944b3c6c9c11b4ce0700c77f190c (diff)
downloadgit-b436825b9bf3c606bb684e41f426fa3d0c088328.zip
git-b436825b9bf3c606bb684e41f426fa3d0c088328.tar.gz
git-b436825b9bf3c606bb684e41f426fa3d0c088328.tar.bz2
git-gui: support for diff3 conflict style
This adds highlight support for the diff3 conflict style. The common pre-image will be reversed to --, because it has been removed and replaced with ours or theirs side respectively. Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com> Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/diff.tcl18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/diff.tcl b/lib/diff.tcl
index 0fd4600..871ad48 100644
--- a/lib/diff.tcl
+++ b/lib/diff.tcl
@@ -347,6 +347,10 @@ proc start_show_diff {cont_info {add_opts {}}} {
}
set ::current_diff_inheader 1
+ # Detect pre-image lines of the diff3 conflict-style. They are just
+ # '++' lines which is not bijective. Thus, we need to maintain a state
+ # across lines.
+ set ::conflict_in_pre_image 0
fconfigure $fd \
-blocking 0 \
-encoding [get_path_encoding $path] \
@@ -449,11 +453,23 @@ proc read_diff {fd conflict_size cont_info} {
{--} {set tags d_--}
{++} {
set regexp [string map [list %conflict_size $conflict_size]\
- {^\+\+([<>=]){%conflict_size}(?: |$)}]
+ {^\+\+([<>=|]){%conflict_size}(?: |$)}]
if {[regexp $regexp $line _g op]} {
set is_conflict_diff 1
set line [string replace $line 0 1 { }]
set tags d$op
+
+ # The ||| conflict-marker marks the start of the pre-image.
+ # All those lines are also prefixed with '++'. Thus we need
+ # to maintain this state.
+ set ::conflict_in_pre_image [expr {$op eq {|}}]
+ } elseif {$::conflict_in_pre_image} {
+ # This is a pre-image line. It is the one which both sides
+ # are based on. As it has also the '++' line start, it is
+ # normally shown as 'added'. Invert this to '--' to make
+ # it a 'removed' line.
+ set line [string replace $line 0 1 {--}]
+ set tags d_--
} else {
set tags d_++
}