]> git.neil.brown.name Git - wiggle.git/commitdiff
merge: remove useless context from the end of a conflict.
authorNeilBrown <neilb@suse.de>
Wed, 13 Feb 2013 23:45:57 +0000 (10:45 +1100)
committerNeilBrown <neilb@suse.de>
Wed, 13 Feb 2013 23:45:57 +0000 (10:45 +1100)
If we are close to the end-of-file, then don't expect
too many unchanged lines.
And allow zero lines of context in the merge if  it is unchanged out
side the merge.

Update various tests to match - all clear improvements.

Signed-off-by: NeilBrown <neilb@suse.de>
merge2.c
tests/linux/raid5build/merge
tests/simple/all-different/merge
tests/simple/conflict/merge
tests/simple/conflictmixed/merge
tests/simple/multiple-add/merge
tests/simple/show-wiggle-1/Wmerge

index b2cc4cfb5b2612bc96dc6c925ad124de1bf6cc6e..9f97c6589b6d86dd340c08f6349b254f479e761b 100644 (file)
--- a/merge2.c
+++ b/merge2.c
@@ -256,7 +256,7 @@ int isolate_conflicts(struct file af, struct file bf, struct file cf,
                                                int firstk = -1;
                                                for (k = 0 ; k < m[j].al ; k++)
                                                        if (ends_line(af.list[m[j].a+k])) {
-                                                               if (firstk <= 0)
+                                                               if (firstk < 0)
                                                                        firstk = k;
                                                                newlines++;
                                                                if (newlines >= 3) {
@@ -264,6 +264,11 @@ int isolate_conflicts(struct file af, struct file bf, struct file cf,
                                                                        break;
                                                                }
                                                        }
+                                               if (newlines < 3 &&
+                                                   m[j+1].type  == End)
+                                                       /* Hit end of file, pretend we found 3 newlines. */
+                                                       k = firstk;
+
                                                if (firstk >= 0 &&
                                                    m[j+1].type == Unmatched) {
                                                        /* If this Unmatched exceeds 3 lines, just stop here */
index 0fe41cd7ab63fcb08f94950a9a50cf1b6db7bdf2..eaff4cefed4de4c30a10c42e998af0759de53894 100644 (file)
@@ -27,12 +27,10 @@ static void raid5_build_block (struct stripe_head *sh, int i)
        bh->b_size      = sh->size;
        bh->b_list      = BUF_LOCKED;
        return bh;
-}
 |||||||
        bh->b_size      = sh->size;
        return bh;
-}
 =======
                dev->sector = compute_blocknr(sh, i);
-}
 >>>>>>>
+}
index 28ee4541ce25b39543f4a45ef6bad07de7926a0a..ab83c87a4f9fd447b15f3b4e00b1a02d403b28e8 100644 (file)
@@ -9,7 +9,6 @@
 8
 9
 0
-yes
 |||||||
 a
 b
@@ -21,7 +20,6 @@ g
 h
 i
 j
-yes
 =======
 A
 B
@@ -33,5 +31,5 @@ G
 H
 I
 J
-yes
 >>>>>>>
+yes
index fb97f49aad2ef971dabc315beb3b920ee6d7b9e7..4afaeff67cd1e19aa6c72d3e127128fd533baf5e 100644 (file)
@@ -2,11 +2,9 @@ this is a file
 with the word
 <<<<<<<
 two which is
-misspelt
 |||||||
 to which is
-misspelt
 =======
 too which is
-misspelt
 >>>>>>>
+misspelt
index 5af8ed0fcc72c7964ce4906b5f838c80e5bc75f6..bb4d03c3f97508a6c868e5dd16fa833460faf831 100644 (file)
@@ -2,11 +2,9 @@ this is a file
 with the word
 <<<<<<<
 two which is
-misspelt
 |||||||
 to which is
-misspelt
 =======
 too which was
-misspelt
 >>>>>>>
+misspelt
index 312609f4dd4548afc9cb6ae2af9e02eeaffee3bf..f2a4151609b7bf486f936a84e93c7d22ea9de316 100644 (file)
@@ -7,11 +7,9 @@ of
 the
 <<<<<<<
 file.
-
 |||||||
 file
-
 =======
 file that has changed
-
 >>>>>>>
+
index 805a091f3d61210d195dd5ebf8c8c33c94aec705..2bb7d411a359a93788b1489f303c8ec07573482a 100644 (file)
@@ -1,17 +1,14 @@
 
 <<<<<<<
 This is one line of the file
-
 |||||||
 This is 1 line of the file
-
 =======
 This is 1 line of the document
-
 &&&&&&&
 This is one line of the document
-
 >>>>>>>
+
 I think this is another line
 
 So is this