Code

git-gui: respect conflict marker size
authorBert Wesarg <bert.wesarg@googlemail.com>
Tue, 16 Nov 2010 09:21:52 +0000 (10:21 +0100)
committerPat Thoyts <patthoyts@users.sourceforge.net>
Fri, 19 Nov 2010 11:25:00 +0000 (11:25 +0000)
Respect the conflict-marker-size attribute on paths when detecting merge
conflicts.

[PT: fixed problem with variable substitution in the regexps]

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
git-gui.sh
lib/diff.tcl

index d3acf0d2134b40b8ffb3d0e8c3229f71fa6db663..38362fa940433712b682aeffcb74c2b8b0feb9d8 100755 (executable)
@@ -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
 
index 0579fa609d191d5dc5244e1f56a3df9daaff9aa3..8fea9477a4215c838f5fdb1f30dcb643a00f76db 100644 (file)
@@ -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} {
@@ -357,7 +371,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
@@ -410,7 +424,9 @@ proc read_diff {fd cont_info} {
                        {- } {set tags d_-s}
                        {--} {set tags d_--}
                        {++} {
-                               if {[regexp {^\+\+([<>]{7} |={7})} $line _g op]} {
+                               set regexp [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
@@ -449,7 +465,9 @@ proc read_diff {fd cont_info} {
                        {@} {set tags d_@}
                        {-} {set tags d_-}
                        {+} {
-                               if {[regexp {^\+([<>]{7} |={7})} $line _g op]} {
+                               set regexp [string map [list %conflict_size $conflict_size]\
+                                                               {^\+([<>=]){%conflict_size}(?: |$)}]
+                               if {[regexp $regexp $line _g op]} {
                                        set is_conflict_diff 1
                                        set tags d$op
                                } else {