From c3b57dc2a0fe944b3c6c9c11b4ce0700c77f190c Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Mon, 30 Sep 2019 21:54:52 +0200 Subject: git-gui: use existing interface to query a path's attribute Replace the hand-coded call to git check-attr with the already provided one. Signed-off-by: Bert Wesarg Signed-off-by: Pratyush Yadav --- lib/diff.tcl | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/lib/diff.tcl b/lib/diff.tcl index 958a0fa219..0fd46003b2 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -270,19 +270,6 @@ proc show_other_diff {path w m cont_info} { } } -proc get_conflict_marker_size {path} { - set size 7 - catch { - set fd_rc [eval [list git_read check-attr "conflict-marker-size" -- $path]] - set ret [gets $fd_rc line] - close $fd_rc - if {$ret > 0} { - regexp {.*: conflict-marker-size: (\d+)$} $line line size - } - } - return $size -} - proc start_show_diff {cont_info {add_opts {}}} { global file_states file_lists global is_3way_diff is_submodule_diff diff_active repo_config @@ -298,7 +285,7 @@ proc start_show_diff {cont_info {add_opts {}}} { set is_submodule_diff 0 set diff_active 1 set current_diff_header {} - set conflict_size [get_conflict_marker_size $path] + set conflict_size [gitattr $path conflict-marker-size 7] set cmd [list] if {$w eq $ui_index} { -- cgit v1.2.3 From b436825b9bf3c606bb684e41f426fa3d0c088328 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Wed, 2 Oct 2019 09:36:02 +0200 Subject: 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 Signed-off-by: Pratyush Yadav --- git-gui.sh | 3 +++ lib/diff.tcl | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/git-gui.sh b/git-gui.sh index fd476b6999..6d80f82c12 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -3581,6 +3581,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 0fd46003b2..871ad488c2 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_++ } -- cgit v1.2.3