git-gui: Include version check and test for tearoff menu entry
[gitweb.git] / lib / diff.tcl
index 20f50ddab2ca7b0fc8d3abec95b74591a1377ceb..cf8a95ec346a9a8afa60a3812d59a8caa4bb4c3f 100644 (file)
@@ -382,6 +382,8 @@ proc read_diff {fd conflict_size cont_info} {
                foreach {line markup} [parse_color_line $line] break
                set line [string map {\033 ^} $line]
 
+               set tags {}
+
                # -- Check for start of diff header.
                if {   [string match {diff --git *}      $line]
                    || [string match {diff --cc *}       $line]
@@ -393,8 +395,19 @@ proc read_diff {fd conflict_size cont_info} {
                #
                if {[regexp {^@@+ } $line]} {set ::current_diff_inheader 0}
 
+               # -- Automatically detect if this is a 3 way diff.
+               #
+               if {[string match {@@@ *} $line]} {set is_3way_diff 1}
+
                if {$::current_diff_inheader} {
-                       append current_diff_header $line "\n"
+
+                       # -- These two lines stop a diff header and shouldn't be in there
+                       if {   [string match {Binary files * and * differ} $line]
+                           || [regexp {^\* Unmerged path }                $line]} {
+                               set ::current_diff_inheader 0
+                       } else {
+                               append current_diff_header $line "\n"
+                       }
 
                        # -- Cleanup uninteresting diff header lines.
                        #
@@ -410,22 +423,9 @@ proc read_diff {fd conflict_size cont_info} {
                        # -- Name it symlink, not 120000
                        #    Note, that the original line is in $current_diff_header
                        regsub {^(deleted|new) file mode 120000} $line {\1 symlink} line
-               }
-
-
-               # -- Automatically detect if this is a 3 way diff.
-               #
-               if {[string match {@@@ *} $line]} {set is_3way_diff 1}
 
-               if {[string match {new file *} $line]
-                       || [regexp {^(old|new) mode *} $line]
-                       || [string match {deleted file *} $line]
-                       || [string match {deleted symlink} $line]
-                       || [string match {new symlink} $line]
-                       || [string match {Binary files * and * differ} $line]
-                       || $line eq {\ No newline at end of file}
-                       || [regexp {^\* Unmerged path } $line]} {
-                       set tags {}
+               } elseif {   $line eq {\ No newline at end of file}} {
+                       # -- Handle some special lines
                } elseif {$is_3way_diff} {
                        set op [string range $line 0 1]
                        switch -- $op {