git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Bert Wesarg <bert.wesarg@googlemail.com>
To: git@vger.kernel.org
Cc: Bert Wesarg <bert.wesarg@googlemail.com>,
	Philip Oakley <philipoakley@iee.email>,
	Pratyush Yadav <me@yadavpratyush.com>
Subject: [PATCH v2 2/2] git-gui: support for diff3 conflict style
Date: Mon, 30 Sep 2019 14:20:07 +0200	[thread overview]
Message-ID: <14754a59ecf15194dccc659072e2bc180280d097.1569845908.git.bert.wesarg@googlemail.com> (raw)
In-Reply-To: <97013a71289857767100d6a4adcb39ca99b2b21b.1569845908.git.bert.wesarg@googlemail.com>

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>
---
 git-gui.sh   |  3 +++
 lib/diff.tcl | 17 ++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/git-gui.sh b/git-gui.sh
index fd476b6..6d80f82 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 0fd4600..6459cfb 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,22 @@ 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_++
 				}
-- 
2.23.0.11.g242cf7f110


  reply	other threads:[~2019-09-30 12:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-25 20:38 [PATCH 1/2] git-gui: use existing interface to query a path's attribute Bert Wesarg
2019-09-25 20:38 ` [PATCH 2/2] git-gui: support for diff3 conflict style Bert Wesarg
2019-09-29 15:04   ` Pratyush Yadav
2019-09-30 12:17     ` Bert Wesarg
2019-09-30 12:20       ` [PATCH v2 1/2] git-gui: use existing interface to query a path's attribute Bert Wesarg
2019-09-30 12:20         ` Bert Wesarg [this message]
2019-09-30 19:54           ` [PATCH v3 " Bert Wesarg
2019-10-01 14:24             ` Pratyush Yadav
2019-10-01 15:22               ` Bert Wesarg
2019-10-01 17:31                 ` Pratyush Yadav
2019-10-02  7:35                   ` Bert Wesarg
2019-10-02  7:36             ` [PATCH v3 2/2] git-gui: support for diff3 conflict style Bert Wesarg
2019-10-02 23:54               ` Pratyush Yadav
2019-10-03 20:02       ` [PATCH " Philip Oakley
2019-10-03 20:54         ` Pratyush Yadav
2019-10-03 21:40           ` Philip Oakley
     [not found]             ` <CAKPyHN0_AUqLpPVDNJUZqNV8zRQzaDOMXJV4AbnK969AdtGpNg@mail.gmail.com>
2019-10-04 16:09               ` Philip Oakley
2019-09-27  5:27 ` [PATCH 1/2] git-gui: use existing interface to query a path's attribute Pratyush Yadav

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14754a59ecf15194dccc659072e2bc180280d097.1569845908.git.bert.wesarg@googlemail.com \
    --to=bert.wesarg@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=me@yadavpratyush.com \
    --cc=philipoakley@iee.email \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).