summaryrefslogtreecommitdiff
path: root/git-gui/lib
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-11-04 04:29:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-11-04 04:29:38 (GMT)
commitab6b50e4c8339167c0b048c778055526226c45ca (patch)
treef378953158b99acafc700cff190ee31b0f964593 /git-gui/lib
parent93bf7423dd21c9d7bf2fd99c97cbfcb74740eac3 (diff)
parentb524f6b399c77b40c8bf2b6217585fde4731472a (diff)
downloadgit-ab6b50e4c8339167c0b048c778055526226c45ca.zip
git-ab6b50e4c8339167c0b048c778055526226c45ca.tar.gz
git-ab6b50e4c8339167c0b048c778055526226c45ca.tar.bz2
Merge https://github.com/prati0100/git-gui
* https://github.com/prati0100/git-gui: git-gui: improve Japanese translation git-gui: add a readme git-gui: support for diff3 conflict style git-gui: use existing interface to query a path's attribute git-gui (Windows): use git-bash.exe if it is available treewide: correct several "up-to-date" to "up to date" Fix build with core.autocrlf=true
Diffstat (limited to 'git-gui/lib')
-rw-r--r--git-gui/lib/diff.tcl33
1 files changed, 18 insertions, 15 deletions
diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
index 958a0fa..871ad48 100644
--- a/git-gui/lib/diff.tcl
+++ b/git-gui/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} {
@@ -360,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] \
@@ -462,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_++
}