From 7ef503bf3c0fd3f5f30f907fa724eb9c5398b945 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Wed, 25 May 2011 18:59:34 +0200 Subject: [PATCH] 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 either replaced with our or their side. Signed-off-by: Bert Wesarg --- git-gui.sh | 3 +++ lib/diff.tcl | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/git-gui.sh b/git-gui.sh index c2859b9..1d220a4 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -3529,6 +3529,9 @@ $ui_diff tag conf d_s- \ $ui_diff tag conf d< \ -foreground orange \ -font font_diffbold +$ui_diff tag conf d| \ + -foreground orange \ + -font font_diffbold $ui_diff tag conf d= \ -foreground orange \ -font font_diffbold diff --git a/lib/diff.tcl b/lib/diff.tcl index 8189542..b140c87 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -327,6 +327,7 @@ proc start_show_diff {cont_info {add_opts {}}} { } set ::current_diff_inheader 1 + set ::conflict_state {CONTEXT} fconfigure $fd \ -blocking 0 \ -encoding [get_path_encoding $path] \ @@ -427,10 +428,28 @@ proc read_diff {fd conflict_size cont_info} { {++} { set regexp [string map [list %conflict_size $conflict_size]\ {^\+\+([<>=]){%conflict_size}(?: |$)}] + set regexp_pre_image [string map [list %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 markup {} set tags d$op + switch -exact -- $op { + < { set ::conflict_state {OURS} } + = { set ::conflict_state {THEIRS} } + > { set ::conflict_state {CONTEXT} } + } + } elseif {[regexp $regexp_pre_image $line]} { + set is_conflict_diff 1 + set line [string replace $line 0 1 { }] + set markup {} + set tags d| + set ::conflict_state {BASE} + } elseif {$::conflict_state eq {BASE}} { + set line [string replace $line 0 1 {--}] + set markup {} + set tags d_-- } else { set tags d_++ } @@ -482,6 +501,9 @@ proc read_diff {fd conflict_size cont_info} { } } set mark [$ui_diff index "end - 1 line linestart"] + if {[llength $markup] > 0} { + set tags {} + } $ui_diff insert end $line $tags if {[string index $line end] eq "\r"} { $ui_diff tag add d_cr {end - 2c} -- 2.11.4.GIT