{"thread":{"id":"51942","subject":"[PATCH v2 1/2] git-gui: use existing interface to query a path's attribute","startedAt":"2019-09-30T12:20:12Z","lastAt":"2019-09-30T12:20:13Z","messageCount":2,"participants":["Bert Wesarg"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"383157","messageId":"97013a71289857767100d6a4adcb39ca99b2b21b.1569845908.git.bert.wesarg@googlemail.com","threadId":"51942","inReplyTo":null,"subject":"[PATCH v2 1/2] git-gui: use existing interface to query a path's attribute","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2019-09-30T12:20:06Z","receivedAt":"2019-09-30T12:20:12Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Replace the hand-coded call to git check-attr with the already provided one.\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n lib/diff.tcl | 15 +--------------\n 1 file changed, 1 insertion(+), 14 deletions(-)\n\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex 958a0fa..0fd4600 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -270,19 +270,6 @@ proc show_other_diff {path w m cont_info} {\n \t}\n }\n \n-proc get_conflict_marker_size {path} {\n-\tset size 7\n-\tcatch {\n-\t\tset fd_rc [eval [list git_read check-attr \"conflict-marker-size\" -- $path]]\n-\t\tset ret [gets $fd_rc line]\n-\t\tclose $fd_rc\n-\t\tif {$ret > 0} {\n-\t\t\tregexp {.*: conflict-marker-size: (\\d+)$} $line line size\n-\t\t}\n-\t}\n-\treturn $size\n-}\n-\n proc start_show_diff {cont_info {add_opts {}}} {\n \tglobal file_states file_lists\n \tglobal is_3way_diff is_submodule_diff diff_active repo_config\n@@ -298,7 +285,7 @@ proc start_show_diff {cont_info {add_opts {}}} {\n \tset is_submodule_diff 0\n \tset diff_active 1\n \tset current_diff_header {}\n-\tset conflict_size [get_conflict_marker_size $path]\n+\tset conflict_size [gitattr $path conflict-marker-size 7]\n \n \tset cmd [list]\n \tif {$w eq $ui_index} {\n-- \n2.23.0.11.g242cf7f110\n\n"},{"id":"383158","messageId":"14754a59ecf15194dccc659072e2bc180280d097.1569845908.git.bert.wesarg@googlemail.com","threadId":"51942","inReplyTo":"97013a71289857767100d6a4adcb39ca99b2b21b.1569845908.git.bert.wesarg@googlemail.com","subject":"[PATCH v2 2/2] git-gui: support for diff3 conflict style","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2019-09-30T12:20:07Z","receivedAt":"2019-09-30T12:20:13Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"This adds highlight support for the diff3 conflict style.\n\nThe common pre-image will be reversed to --, because it has been removed\nand replaced with ours or theirs side respectively.\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n git-gui.sh   |  3 +++\n lib/diff.tcl | 17 ++++++++++++++++-\n 2 files changed, 19 insertions(+), 1 deletion(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex fd476b6..6d80f82 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -3581,6 +3581,9 @@ $ui_diff tag conf d_s- \\\n $ui_diff tag conf d< \\\n \t-foreground orange \\\n \t-font font_diffbold\n+$ui_diff tag conf d| \\\n+\t-foreground orange \\\n+\t-font font_diffbold\n $ui_diff tag conf d= \\\n \t-foreground orange \\\n \t-font font_diffbold\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex 0fd4600..6459cfb 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -347,6 +347,10 @@ proc start_show_diff {cont_info {add_opts {}}} {\n \t}\n \n \tset ::current_diff_inheader 1\n+\t# detect pre-image lines of the diff3 conflict-style, they are just '++'\n+\t# lines which is not bijective, thus we need to maintain a state across\n+\t# lines\n+\tset ::conflict_in_pre_image 0\n \tfconfigure $fd \\\n \t\t-blocking 0 \\\n \t\t-encoding [get_path_encoding $path] \\\n@@ -449,11 +453,22 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t\t{--} {set tags d_--}\n \t\t\t{++} {\n \t\t\t\tset regexp [string map [list %conflict_size $conflict_size]\\\n-\t\t\t\t\t\t\t\t{^\\+\\+([<>=]){%conflict_size}(?: |$)}]\n+\t\t\t\t\t\t\t\t{^\\+\\+([<>=|]){%conflict_size}(?: |$)}]\n \t\t\t\tif {[regexp $regexp $line _g op]} {\n \t\t\t\t\tset is_conflict_diff 1\n \t\t\t\t\tset line [string replace $line 0 1 {  }]\n \t\t\t\t\tset tags d$op\n+\t\t\t\t\t# the ||| conflict-marker marks the start of the pre-image,\n+\t\t\t\t\t# all those lines are also prefixed with '++', thus we need\n+\t\t\t\t\t# to maintain this state\n+\t\t\t\t\tset ::conflict_in_pre_image [expr {$op eq {|}}\n+\t\t\t\t} elseif {$::conflict_in_pre_image} {\n+\t\t\t\t\t# this is a pre-image line, it is the one which both sides\n+\t\t\t\t\t# are based on. As it has also the '++' line start, it is\n+\t\t\t\t\t# normally shown as 'added', invert this to '--' to make\n+\t\t\t\t\t# it a 'removed' line\n+\t\t\t\t\tset line [string replace $line 0 1 {--}]\n+\t\t\t\t\tset tags d_--\n \t\t\t\t} else {\n \t\t\t\t\tset tags d_++\n \t\t\t\t}\n-- \n2.23.0.11.g242cf7f110\n\n"}]}