# [PATCH] git-gui: respect conflict marker size

11 messages from 2010-11-16 to 2011-10-20. Participants: Bert Wesarg, Pat Thoyts.
Thread: https://gitlist.dev/t/25758

## Bert Wesarg, 2010-11-16 07:49

Subject: [PATCH] git-gui: respect conflict marker size
Message-ID: <1289893762-28567-1-git-send-email-bert.wesarg@googlemail.com>
URL: https://gitlist.dev/e/1289893762-28567-1-git-send-email-bert.wesarg%40googlemail.com

```
Respect the conflict-marker-size attribute on paths when detecting merge
conflicts.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>

---
 git-gui/lib/diff.tcl |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
index dcf0711..a753737 100644
--- a/git-gui/lib/diff.tcl
+++ b/git-gui/lib/diff.tcl
@@ -253,6 +253,19 @@ 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
@@ -268,6 +281,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 cmd [list]
 	if {$w eq $ui_index} {
@@ -329,7 +343,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
 		-blocking 0 \
 		-encoding [get_path_encoding $path] \
 		-translation lf
-	fileevent $fd readable [list read_diff $fd $cont_info]
+	fileevent $fd readable [list read_diff $fd $conflict_size $cont_info]
 }
 
 proc parse_color_line {line} {
@@ -349,7 +363,7 @@ proc parse_color_line {line} {
 	return [list $result $markup]
 }
 
-proc read_diff {fd cont_info} {
+proc read_diff {fd conflict_size cont_info} {
 	global ui_diff diff_active is_submodule_diff
 	global is_3way_diff is_conflict_diff current_diff_header
 	global current_diff_queue
@@ -402,7 +416,7 @@ proc read_diff {fd cont_info} {
 			{- } {set tags d_-s}
 			{--} {set tags d_--}
 			{++} {
-				if {[regexp {^\+\+([<>]{7} |={7})} $line _g op]} {
+				if {[regexp {^\+\+([<>]{$conflict_size} |={$conflict_size})} $line _g op]} {
 					set is_conflict_diff 1
 					set line [string replace $line 0 1 {  }]
 					set tags d$op
@@ -441,7 +455,7 @@ proc read_diff {fd cont_info} {
 			{@} {set tags d_@}
 			{-} {set tags d_-}
 			{+} {
-				if {[regexp {^\+([<>]{7} |={7})} $line _g op]} {
+				if {[regexp {^\+([<>]{$conflict_size} |={$conflict_size})} $line _g op]} {
 					set is_conflict_diff 1
 					set tags d$op
 				} else {
-- 
tg: (6f10c41..) bw/git-gui/respect-conflict-marker-size (depends on: master)

```

## Bert Wesarg, 2010-11-16 09:21

Subject: [PATCHv2 1/2] git-gui: respect conflict marker size
Message-ID: <1289899312-2732-1-git-send-email-bert.wesarg@googlemail.com>
URL: https://gitlist.dev/e/1289899312-2732-1-git-send-email-bert.wesarg%40googlemail.com
In-Reply-To: <1289893762-28567-1-git-send-email-bert.wesarg@googlemail.com>

```
Respect the conflict-marker-size attribute on paths when detecting merge
conflicts.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>

---

v2 fixes the tags selection and also the regexp to match always exactly the
desired number of markers.

Bert

 git-gui/git-gui.sh   |    6 +++---
 git-gui/lib/diff.tcl |   22 ++++++++++++++++++----
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index d3acf0d..38362fa 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -3351,13 +3351,13 @@ $ui_diff tag conf d_s- \
 	-foreground red \
 	-background ivory1
 
-$ui_diff tag conf d<<<<<<< \
+$ui_diff tag conf d< \
 	-foreground orange \
 	-font font_diffbold
-$ui_diff tag conf d======= \
+$ui_diff tag conf d= \
 	-foreground orange \
 	-font font_diffbold
-$ui_diff tag conf d>>>>>>> \
+$ui_diff tag conf d> \
 	-foreground orange \
 	-font font_diffbold
 
diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
index dcf0711..d4e2ce3 100644
--- a/git-gui/lib/diff.tcl
+++ b/git-gui/lib/diff.tcl
@@ -253,6 +253,19 @@ 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
@@ -268,6 +281,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 cmd [list]
 	if {$w eq $ui_index} {
@@ -329,7 +343,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
 		-blocking 0 \
 		-encoding [get_path_encoding $path] \
 		-translation lf
-	fileevent $fd readable [list read_diff $fd $cont_info]
+	fileevent $fd readable [list read_diff $fd $conflict_size $cont_info]
 }
 
 proc parse_color_line {line} {
@@ -349,7 +363,7 @@ proc parse_color_line {line} {
 	return [list $result $markup]
 }
 
-proc read_diff {fd cont_info} {
+proc read_diff {fd conflict_size cont_info} {
 	global ui_diff diff_active is_submodule_diff
 	global is_3way_diff is_conflict_diff current_diff_header
 	global current_diff_queue
@@ -402,7 +416,7 @@ proc read_diff {fd cont_info} {
 			{- } {set tags d_-s}
 			{--} {set tags d_--}
 			{++} {
-				if {[regexp {^\+\+([<>]{7} |={7})} $line _g op]} {
+				if {[regexp {^\+\+([<>=]){$conflict_size}(?: |$)} $line _g op]} {
 					set is_conflict_diff 1
 					set line [string replace $line 0 1 {  }]
 					set tags d$op
@@ -441,7 +455,7 @@ proc read_diff {fd cont_info} {
 			{@} {set tags d_@}
 			{-} {set tags d_-}
 			{+} {
-				if {[regexp {^\+([<>]{7} |={7})} $line _g op]} {
+				if {[regexp {^\+([<>=]){$conflict_size}(?: |$)} $line _g op]} {
 					set is_conflict_diff 1
 					set tags d$op
 				} else {
-- 
tg: (6f10c41..) bw/git-gui/respect-conflict-marker-size (depends on: master)

```

## Bert Wesarg, 2010-11-16 09:26

Subject: [PATCH 2/2] git-gui: support for diff3 conflict style
Message-ID: <1289899618-2845-1-git-send-email-bert.wesarg@googlemail.com>
URL: https://gitlist.dev/e/1289899618-2845-1-git-send-email-bert.wesarg%40googlemail.com
In-Reply-To: <1289899312-2732-1-git-send-email-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 our or their side.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>

---
 git-gui/git-gui.sh   |    3 +++
 git-gui/lib/diff.tcl |   10 ++++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 38362fa..0134438 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -3354,6 +3354,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/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
index d4e2ce3..ccd4c70 100644
--- a/git-gui/lib/diff.tcl
+++ b/git-gui/lib/diff.tcl
@@ -339,6 +339,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
 	}
 
 	set ::current_diff_inheader 1
+	set ::in_conflict_pre_image 0
 	fconfigure $fd \
 		-blocking 0 \
 		-encoding [get_path_encoding $path] \
@@ -420,6 +421,15 @@ proc read_diff {fd conflict_size cont_info} {
 					set is_conflict_diff 1
 					set line [string replace $line 0 1 {  }]
 					set tags d$op
+					set ::in_conflict_pre_image 0
+				} elseif {[regexp {^\+\+\|{$conflict_size}(?: |$)} $line]} {
+					set is_conflict_diff 1
+					set line [string replace $line 0 1 {  }]
+					set tags d|
+					set ::in_conflict_pre_image 1
+				} elseif ($::in_conflict_pre_image) {
+					set line [string replace $line 0 1 {--}]
+					set tags d_--
 				} else {
 					set tags d_++
 				}
-- 
tg: (fba7c96..) bw/git-gui/support-diff3 (depends on: master bw/git-gui/respect-conflict-marker-size)

```

## Pat Thoyts, 2010-11-19 11:20

Subject: Re: [PATCHv2 1/2] git-gui: respect conflict marker size
Message-ID: <87k4k9h858.fsf@fox.patthoyts.tk>
URL: https://gitlist.dev/e/87k4k9h858.fsf%40fox.patthoyts.tk
In-Reply-To: <1289899312-2732-1-git-send-email-bert.wesarg@googlemail.com>

```
Bert Wesarg <bert.wesarg@googlemail.com> writes:

>Respect the conflict-marker-size attribute on paths when detecting merge
>conflicts.
>
>Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
>
>---
>
>v2 fixes the tags selection and also the regexp to match always exactly the
>desired number of markers.
>
>Bert
>
> git-gui/git-gui.sh   |    6 +++---
> git-gui/lib/diff.tcl |   22 ++++++++++++++++++----
> 2 files changed, 21 insertions(+), 7 deletions(-)
>
>diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
>index d3acf0d..38362fa 100755
>--- a/git-gui/git-gui.sh
>+++ b/git-gui/git-gui.sh
>@@ -3351,13 +3351,13 @@ $ui_diff tag conf d_s- \
> 	-foreground red \
> 	-background ivory1
> 
>-$ui_diff tag conf d<<<<<<< \
>+$ui_diff tag conf d< \
> 	-foreground orange \
> 	-font font_diffbold
>-$ui_diff tag conf d======= \
>+$ui_diff tag conf d= \
> 	-foreground orange \
> 	-font font_diffbold
>-$ui_diff tag conf d>>>>>>> \
>+$ui_diff tag conf d> \
> 	-foreground orange \
> 	-font font_diffbold
> 
>diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
>index dcf0711..d4e2ce3 100644
>--- a/git-gui/lib/diff.tcl
>+++ b/git-gui/lib/diff.tcl
>@@ -253,6 +253,19 @@ 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
>@@ -268,6 +281,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 cmd [list]
> 	if {$w eq $ui_index} {
>@@ -329,7 +343,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
> 		-blocking 0 \
> 		-encoding [get_path_encoding $path] \
> 		-translation lf
>-	fileevent $fd readable [list read_diff $fd $cont_info]
>+	fileevent $fd readable [list read_diff $fd $conflict_size $cont_info]
> }
> 
> proc parse_color_line {line} {
>@@ -349,7 +363,7 @@ proc parse_color_line {line} {
> 	return [list $result $markup]
> }
> 
>-proc read_diff {fd cont_info} {
>+proc read_diff {fd conflict_size cont_info} {
> 	global ui_diff diff_active is_submodule_diff
> 	global is_3way_diff is_conflict_diff current_diff_header
> 	global current_diff_queue
>@@ -402,7 +416,7 @@ proc read_diff {fd cont_info} {
> 			{- } {set tags d_-s}
> 			{--} {set tags d_--}
> 			{++} {
>-				if {[regexp {^\+\+([<>]{7} |={7})} $line _g op]} {
>+				if {[regexp {^\+\+([<>=]){$conflict_size}(?: |$)} $line _g op]} {
> 					set is_conflict_diff 1
> 					set line [string replace $line 0 1 {  }]
> 					set tags d$op
>@@ -441,7 +455,7 @@ proc read_diff {fd cont_info} {
> 			{@} {set tags d_@}
> 			{-} {set tags d_-}
> 			{+} {
>-				if {[regexp {^\+([<>]{7} |={7})} $line _g op]} {
>+				if {[regexp {^\+([<>=]){$conflict_size}(?: |$)} $line _g op]} {
> 					set is_conflict_diff 1
> 					set tags d$op
> 				} else {

Tcl doesn't expand variables in curly-braced expressions so the
$conflict_size is left in there verbatim.

Either 
  set regexp [string map [list %conflict_size $conflict_size]\
      {^\+([<>=]){%conflict_size}(?: |$)}]
which substitutes in the expanded value or double-quotes with care to
protect anything that Tcl would expand in the regexp. The string map
style is often easier to read.
  regexp "^\\+(\[<>=\]){$conflict_size}(?: |\$)" $line _g op

I've squashed in a fix using string map on this one. With that it
appears to work fine. I never noticed this attribute before.

-- 
Pat Thoyts                            http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD

```

## Pat Thoyts, 2010-11-19 11:41

Subject: Re: [PATCH 2/2] git-gui: support for diff3 conflict style
Message-ID: <87fwuxh75m.fsf@fox.patthoyts.tk>
URL: https://gitlist.dev/e/87fwuxh75m.fsf%40fox.patthoyts.tk
In-Reply-To: <1289899618-2845-1-git-send-email-bert.wesarg@googlemail.com>

```
Bert Wesarg <bert.wesarg@googlemail.com> writes:

>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 our or their side.
>
>Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
>
>---
> git-gui/git-gui.sh   |    3 +++
> git-gui/lib/diff.tcl |   10 ++++++++++
> 2 files changed, 13 insertions(+), 0 deletions(-)
>
>diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
>index 38362fa..0134438 100755
>--- a/git-gui/git-gui.sh
>+++ b/git-gui/git-gui.sh
>@@ -3354,6 +3354,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/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
>index d4e2ce3..ccd4c70 100644
>--- a/git-gui/lib/diff.tcl
>+++ b/git-gui/lib/diff.tcl
>@@ -339,6 +339,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
> 	}
> 
> 	set ::current_diff_inheader 1
>+	set ::in_conflict_pre_image 0
> 	fconfigure $fd \
> 		-blocking 0 \
> 		-encoding [get_path_encoding $path] \
>@@ -420,6 +421,15 @@ proc read_diff {fd conflict_size cont_info} {
> 					set is_conflict_diff 1
> 					set line [string replace $line 0 1 {  }]
> 					set tags d$op
>+					set ::in_conflict_pre_image 0
>+				} elseif {[regexp {^\+\+\|{$conflict_size}(?: |$)} $line]} {
>+					set is_conflict_diff 1
>+					set line [string replace $line 0 1 {  }]
>+					set tags d|
>+					set ::in_conflict_pre_image 1
>+				} elseif ($::in_conflict_pre_image) {
>+					set line [string replace $line 0 1 {--}]
>+					set tags d_--
> 				} else {
> 					set tags d_++
> 				}

This has the same issue as the last patch with variable substitution
into the regexp. Replaced the regexp expression with
   [regexp "^\\+\\+\\|{$conflict_size}(?: |\$)" $line]

I configured a test repository with
'merge.conflictstyle diff3' and could test this. Looks fine.
-- 
Pat Thoyts                            http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD

```

## Bert Wesarg, 2010-11-19 11:48

Subject: Re: [PATCHv2 1/2] git-gui: respect conflict marker size
Message-ID: <AANLkTimSU9RfFNpXi3u7BN+eFGBSOaPXS4OOfDmwYaDB@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTimSU9RfFNpXi3u7BN%2BeFGBSOaPXS4OOfDmwYaDB%40mail.gmail.com
In-Reply-To: <87k4k9h858.fsf@fox.patthoyts.tk>

```
On Fri, Nov 19, 2010 at 12:20, Pat Thoyts
<patthoyts@users.sourceforge.net> wrote:
> Tcl doesn't expand variables in curly-braced expressions so the
> $conflict_size is left in there verbatim.

I should have noticed it either by testing or by wondering why i
didn't need to escape the '$', which I have tested but with a verbatim
7 as the conflict_size in the regex.

Thanks for fixing.

Bert

```

## Bert Wesarg, 2010-11-19 12:05

Subject: Re: [PATCH 2/2] git-gui: support for diff3 conflict style
Message-ID: <AANLkTi=Ccc3AWQaFQdkCA=2Y5RJY7dE-6JFJ0vnpnjvf@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTi%3DCcc3AWQaFQdkCA%3D2Y5RJY7dE-6JFJ0vnpnjvf%40mail.gmail.com
In-Reply-To: <87fwuxh75m.fsf@fox.patthoyts.tk>

```
On Fri, Nov 19, 2010 at 12:41, Pat Thoyts
<patthoyts@users.sourceforge.net> wrote:
> Bert Wesarg <bert.wesarg@googlemail.com> writes:
>
>>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 our or their side.
>>
>>Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
>>
>>---
>> git-gui/git-gui.sh   |    3 +++
>> git-gui/lib/diff.tcl |   10 ++++++++++
>> 2 files changed, 13 insertions(+), 0 deletions(-)
>>
>>diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
>>index 38362fa..0134438 100755
>>--- a/git-gui/git-gui.sh
>>+++ b/git-gui/git-gui.sh
>>@@ -3354,6 +3354,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/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
>>index d4e2ce3..ccd4c70 100644
>>--- a/git-gui/lib/diff.tcl
>>+++ b/git-gui/lib/diff.tcl
>>@@ -339,6 +339,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
>>       }
>>
>>       set ::current_diff_inheader 1
>>+      set ::in_conflict_pre_image 0
>>       fconfigure $fd \
>>               -blocking 0 \
>>               -encoding [get_path_encoding $path] \
>>@@ -420,6 +421,15 @@ proc read_diff {fd conflict_size cont_info} {
>>                                       set is_conflict_diff 1
>>                                       set line [string replace $line 0 1 {  }]
>>                                       set tags d$op
>>+                                      set ::in_conflict_pre_image 0
>>+                              } elseif {[regexp {^\+\+\|{$conflict_size}(?: |$)} $line]} {
>>+                                      set is_conflict_diff 1
>>+                                      set line [string replace $line 0 1 {  }]
>>+                                      set tags d|
>>+                                      set ::in_conflict_pre_image 1
>>+                              } elseif ($::in_conflict_pre_image) {
>>+                                      set line [string replace $line 0 1 {--}]
>>+                                      set tags d_--
>>                               } else {
>>                                       set tags d_++
>>                               }
>
> This has the same issue as the last patch with variable substitution
> into the regexp. Replaced the regexp expression with
>   [regexp "^\\+\\+\\|{$conflict_size}(?: |\$)" $line]
>
> I configured a test repository with
> 'merge.conflictstyle diff3' and could test this. Looks fine.

Thanks Pat.

By looking over the patch (which by itself is now some month old) I
wondered whether git-gui has some policy to show the diff output as
verbatim as possible. Which I break with this patch, because I replace
the ++ line prefix in the pre-image with -- and in the |||| lines with
"  ". Shawn, does such policy exists?

Bert

> --
> Pat Thoyts                            http://www.patthoyts.tk/
> PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD
>

```

## Bert Wesarg, 2011-02-27 20:15

Subject: Re: [PATCH 2/2] git-gui: support for diff3 conflict style
Message-ID: <AANLkTin4-1_bNuH2kQ0m6wpevnO5uCJUmLvy=gP4mLfH@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTin4-1_bNuH2kQ0m6wpevnO5uCJUmLvy%3DgP4mLfH%40mail.gmail.com
In-Reply-To: <87fwuxh75m.fsf@fox.patthoyts.tk>

```
On Fri, Nov 19, 2010 at 12:41, Pat Thoyts
<patthoyts@users.sourceforge.net> wrote:
> Bert Wesarg <bert.wesarg@googlemail.com> writes:
>
>>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 our or their side.
>>
>>Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
>>
>>---
>> git-gui/git-gui.sh   |    3 +++
>> git-gui/lib/diff.tcl |   10 ++++++++++
>> 2 files changed, 13 insertions(+), 0 deletions(-)
>>
>>diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
>>index 38362fa..0134438 100755
>>--- a/git-gui/git-gui.sh
>>+++ b/git-gui/git-gui.sh
>>@@ -3354,6 +3354,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/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
>>index d4e2ce3..ccd4c70 100644
>>--- a/git-gui/lib/diff.tcl
>>+++ b/git-gui/lib/diff.tcl
>>@@ -339,6 +339,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
>>       }
>>
>>       set ::current_diff_inheader 1
>>+      set ::in_conflict_pre_image 0
>>       fconfigure $fd \
>>               -blocking 0 \
>>               -encoding [get_path_encoding $path] \
>>@@ -420,6 +421,15 @@ proc read_diff {fd conflict_size cont_info} {
>>                                       set is_conflict_diff 1
>>                                       set line [string replace $line 0 1 {  }]
>>                                       set tags d$op
>>+                                      set ::in_conflict_pre_image 0
>>+                              } elseif {[regexp {^\+\+\|{$conflict_size}(?: |$)} $line]} {
>>+                                      set is_conflict_diff 1
>>+                                      set line [string replace $line 0 1 {  }]
>>+                                      set tags d|
>>+                                      set ::in_conflict_pre_image 1
>>+                              } elseif ($::in_conflict_pre_image) {
>>+                                      set line [string replace $line 0 1 {--}]
>>+                                      set tags d_--
>>                               } else {
>>                                       set tags d_++
>>                               }
>
> This has the same issue as the last patch with variable substitution
> into the regexp. Replaced the regexp expression with
>   [regexp "^\\+\\+\\|{$conflict_size}(?: |\$)" $line]
>
> I configured a test repository with
> 'merge.conflictstyle diff3' and could test this. Looks fine.

I miss this one in git-gui.git

Thanks,
Bert

> --
> Pat Thoyts                            http://www.patthoyts.tk/
> PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD
>

```

## Bert Wesarg, 2011-03-30 06:44

Subject: [PATCH 2/2] git-gui: support for diff3 conflict style
Message-ID: <56c38bdfd71d8af5633bea00cb130256d6981af5.1301467146.git.bert.wesarg@googlemail.com>
URL: https://gitlist.dev/e/56c38bdfd71d8af5633bea00cb130256d6981af5.1301467146.git.bert.wesarg%40googlemail.com
In-Reply-To: <AANLkTin4-1_bNuH2kQ0m6wpevnO5uCJUmLvy=gP4mLfH@mail.gmail.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 our or their side.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---

Maybe it's not too late for the next release.

 git-gui.sh   |    3 +++
 lib/diff.tcl |   12 ++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/git-gui.sh b/git-gui.sh
index d5c1535..6adcda6 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -3388,6 +3388,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 39e4d90..11f9e16 100644
--- a/lib/diff.tcl
+++ b/lib/diff.tcl
@@ -339,6 +339,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
 	}
 
 	set ::current_diff_inheader 1
+	set ::in_conflict_pre_image 0
 	fconfigure $fd \
 		-blocking 0 \
 		-encoding [get_path_encoding $path] \
@@ -439,10 +440,21 @@ 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 tags d$op
+					set ::in_conflict_pre_image 0
+				} elseif {[regexp $regexp_pre_image $line]} {
+					set is_conflict_diff 1
+					set line [string replace $line 0 1 {  }]
+					set tags d|
+					set ::in_conflict_pre_image 1
+				} elseif ($::in_conflict_pre_image) {
+					set line [string replace $line 0 1 {--}]
+					set tags d_--
 				} else {
 					set tags d_++
 				}
-- 
1.7.4.1.1319.ga04f7.dirty

```

## Bert Wesarg, 2011-03-30 07:18

Subject: [PATCH 2v2/2] git-gui: support for diff3 conflict style
Message-ID: <c761e522cce009a70d9131f0a5a1a2fc6aa6d9ac.1301469420.git.bert.wesarg@googlemail.com>
URL: https://gitlist.dev/e/c761e522cce009a70d9131f0a5a1a2fc6aa6d9ac.1301469420.git.bert.wesarg%40googlemail.com
In-Reply-To: <56c38bdfd71d8af5633bea00cb130256d6981af5.1301467146.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 our or their side.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---

Sorry, I had an syntax error in the last version.

 git-gui.sh   |    3 +++
 lib/diff.tcl |   12 ++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/git-gui.sh b/git-gui.sh
index d5c1535..6adcda6 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -3388,6 +3388,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 39e4d90..caa4be7 100644
--- a/lib/diff.tcl
+++ b/lib/diff.tcl
@@ -339,6 +339,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
 	}
 
 	set ::current_diff_inheader 1
+	set ::in_conflict_pre_image 0
 	fconfigure $fd \
 		-blocking 0 \
 		-encoding [get_path_encoding $path] \
@@ -439,10 +440,21 @@ 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 tags d$op
+					set ::in_conflict_pre_image 0
+				} elseif {[regexp $regexp_pre_image $line]} {
+					set is_conflict_diff 1
+					set line [string replace $line 0 1 {  }]
+					set tags d|
+					set ::in_conflict_pre_image 1
+				} elseif ($::in_conflict_pre_image) {
+					set line [string replace $line 0 1 {--}]
+					set tags d_--
 				} else {
 					set tags d_++
 				}
-- 
1.7.4.2.743.g539ab

```

## Bert Wesarg, 2011-10-20 19:35

Subject: Re: [PATCH 2v2/2] git-gui: support for diff3 conflict style
Message-ID: <CAKPyHN2pOJfm=Ys+giv-4ERjzzje1VigxfEKKY-yPsE03A0NNA@mail.gmail.com>
URL: https://gitlist.dev/e/CAKPyHN2pOJfm%3DYs%2Bgiv-4ERjzzje1VigxfEKKY-yPsE03A0NNA%40mail.gmail.com
In-Reply-To: <c761e522cce009a70d9131f0a5a1a2fc6aa6d9ac.1301469420.git.bert.wesarg@googlemail.com>

```
Ping.

On Wed, Mar 30, 2011 at 09:18, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
> 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 our or their side.
>
> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
> ---
>
> Sorry, I had an syntax error in the last version.
>
>  git-gui.sh   |    3 +++
>  lib/diff.tcl |   12 ++++++++++++
>  2 files changed, 15 insertions(+), 0 deletions(-)
>
> diff --git a/git-gui.sh b/git-gui.sh
> index d5c1535..6adcda6 100755
> --- a/git-gui.sh
> +++ b/git-gui.sh
> @@ -3388,6 +3388,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 39e4d90..caa4be7 100644
> --- a/lib/diff.tcl
> +++ b/lib/diff.tcl
> @@ -339,6 +339,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
>        }
>
>        set ::current_diff_inheader 1
> +       set ::in_conflict_pre_image 0
>        fconfigure $fd \
>                -blocking 0 \
>                -encoding [get_path_encoding $path] \
> @@ -439,10 +440,21 @@ 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 tags d$op
> +                                       set ::in_conflict_pre_image 0
> +                               } elseif {[regexp $regexp_pre_image $line]} {
> +                                       set is_conflict_diff 1
> +                                       set line [string replace $line 0 1 {  }]
> +                                       set tags d|
> +                                       set ::in_conflict_pre_image 1
> +                               } elseif ($::in_conflict_pre_image) {
> +                                       set line [string replace $line 0 1 {--}]
> +                                       set tags d_--
>                                } else {
>                                        set tags d_++
>                                }
> --
> 1.7.4.2.743.g539ab
>
>

```
