All of lore.kernel.org
 help / color / mirror / 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 2/2] git-gui: support for diff3 conflict style
Date: Wed, 25 Sep 2019 22:38:51 +0200	[thread overview]
Message-ID: <f1477ba53a03484a0440202065a5293c8795d3b7.1569443729.git.bert.wesarg@googlemail.com> (raw)
In-Reply-To: <97013a71289857767100d6a4adcb39ca99b2b21b.1569443729.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 either replaced with ours or theirs side.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 git-gui.sh   |  3 +++
 lib/diff.tcl | 22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+)

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..6caf4e7 100644
--- a/lib/diff.tcl
+++ b/lib/diff.tcl
@@ -347,6 +347,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] \
@@ -450,10 +451,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_++
 				}
@@ -505,6 +524,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.21.0.789.ga095d9d866


  reply	other threads:[~2019-09-25 20:38 UTC|newest]

Thread overview: 23+ 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 ` Bert Wesarg [this message]
2019-09-29 15:04   ` [PATCH 2/2] git-gui: support for diff3 conflict style 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         ` [PATCH v2 2/2] git-gui: support for diff3 conflict style Bert Wesarg
2019-09-30 19:54           ` [PATCH v3 1/2] git-gui: use existing interface to query a path's attribute 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
  -- strict thread matches above, loose matches on Subject: below --
2011-03-30  6:44 [PATCH 1/2] git-gui: support for underline styles Bert Wesarg
2010-11-16  9:21 [PATCHv2 1/2] git-gui: respect conflict marker size Bert Wesarg
2010-11-16  9:26 ` [PATCH 2/2] git-gui: support for diff3 conflict style Bert Wesarg
2010-11-19 11:41   ` Pat Thoyts
2010-11-19 12:05     ` Bert Wesarg
2011-02-27 20:15     ` Bert Wesarg
2011-03-30  6:44       ` Bert Wesarg

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

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

  git send-email \
    --in-reply-to=f1477ba53a03484a0440202065a5293c8795d3b7.1569443729.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.