]> git.neil.brown.name Git - wiggle.git/commitdiff
Add --no-ignore option
authorNeil Brown <neilb@suse.de>
Wed, 24 Mar 2010 08:03:39 +0000 (19:03 +1100)
committerNeil Brown <neilb@suse.de>
Wed, 24 Mar 2010 08:03:39 +0000 (19:03 +1100)
This suppresses the optimisation of ignoring conflicts which appear to
be making a change that had already been made.

Signed-off-by: NeilBrown <neilb@suse.de>
ReadMe.c
merge2.c
vpatch.c
wiggle.1
wiggle.c
wiggle.h

index fad18889941c6187fa22dc1f020e170758bf21e5..84c5c476831a15ae84de253169a808bad3895294 100644 (file)
--- a/ReadMe.c
+++ b/ReadMe.c
@@ -31,8 +31,8 @@
 
 char Version[] = "wiggle - v0.7 - 24 March 2010\n";
 
-char short_options1[]="xdmwlrh123pVRvqB"; /* not mode B */
-char short_options2[]="xdmwlrh123p:VRvqB"; /* mode B */
+char short_options1[]="xdmwlrhi123pVRvqB"; /* not mode B */
+char short_options2[]="xdmwlrhi123p:VRvqB"; /* mode B */
 
 
 struct option long_options[] = {
@@ -50,6 +50,7 @@ struct option long_options[] = {
        {"verbose",     0, 0, 'v'},
        {"quiet",       0, 0, 'q'},
        {"strip",       1, 0, 'p'},
+       {"no-ignore",   0, 0, 'i'},
        {0, 0, 0, 0}
 };
 
index 768baeea506327d5a9ecebcf0c839850f67b6b6c..592157c1b9259f751cd2fd01cbd7a610eda07904 100644 (file)
--- a/merge2.c
+++ b/merge2.c
@@ -220,7 +220,8 @@ inline int isolate_conflicts(struct file af, struct file bf, struct file cf,
 
 
 struct ci make_merger(struct file af, struct file bf, struct file cf,
-                     struct csl *csl1, struct csl *csl2, int words)
+                     struct csl *csl1, struct csl *csl2, int words,
+                     int ignore_already)
 {
        /* find the wiggles and conflicts between csl1 and csl2
         */
@@ -318,7 +319,8 @@ struct ci make_merger(struct file af, struct file bf, struct file cf,
                        rv.merger[i].al = csl1[c1].a - a;
                        rv.merger[i].cl = csl2[c2].b - c;
                        rv.merger[i].bl = min(csl1[c1].b, csl2[c2].a) - b;
-                       if (check_alreadyapplied(af,cf,&rv.merger[i]))
+                       if (ignore_already &&
+                           check_alreadyapplied(af,cf,&rv.merger[i]))
                                rv.ignored ++;
                }
                a += rv.merger[i].al;
@@ -353,10 +355,11 @@ void printrange(FILE *out, struct file *f, int start, int len)
 }
 
 struct ci print_merge2(FILE *out, struct file *a, struct file *b, struct file *c,
-                struct csl *c1, struct csl *c2,
-                int words)
+                      struct csl *c1, struct csl *c2,
+                      int words, int ignore_already)
 {
-       struct ci rv = make_merger(*a, *b, *c, c1, c2, words);
+       struct ci rv = make_merger(*a, *b, *c, c1, c2, 
+                                  words, ignore_already);
        struct merge *m;
 
        for (m=rv.merger; m->type != End ; m++) {
index 1813a3d2d53010d05a9b3df9978538c6ebf57d3d..f336180a4e18a984d84b055110eeb853f47619a1 100644 (file)
--- a/vpatch.c
+++ b/vpatch.c
@@ -425,7 +425,7 @@ void draw_one(int row, struct plist *pl, FILE *f, int reverse)
                        fp2 = split_stream(s2, ByWord, 0);
                        csl1 = pdiff(ff, fp1, pl->chunks);
                        csl2 = diff(fp1,fp2);
-                       ci = make_merger(ff, fp1, fp2, csl1, csl2, 0);
+                       ci = make_merger(ff, fp1, fp2, csl1, csl2, 0, 1);
                        pl->wiggles = ci.wiggles;
                        pl->conflicts = ci.conflicts;
                        free(csl1);
@@ -1387,7 +1387,7 @@ void merge_window(struct plist *p, FILE *f, int reverse)
        cleanlist(fb, fa, csl2);
 #endif
 
-       ci = make_merger(fm, fb, fa, csl1, csl2, 0);
+       ci = make_merger(fm, fb, fa, csl1, csl2, 0, 1);
 
        row = 1;
        pos.p.m = 0; /* merge node */
index c4f2a6ec01d88ea48d837f3103de76219c871b07..8967b0caaf63efa29583135e1ec1d5e7ee585c0a 100644 (file)
--- a/wiggle.1
+++ b/wiggle.1
@@ -156,6 +156,12 @@ When used with the "merge" function,
 .I wiggle
 attempts to revert changes rather than apply them.
 
+.TP
+.BR -i ", " \-\-no\-ignore
+Normally wiggle with ignore changes in the patch which appear to
+already have been applied in the original.  With this flag those
+changes are reported as conflicts rather than being ignored.
+
 .TP
 .BR -h ", " \-\-help
 Print a simple help message.  If given after one of the function
@@ -290,6 +296,9 @@ in the original, then it is assumed that this change has already been
 applied, and the change is ignored.  When this happens, a message
 reflected the number of ignored changes is printed by
 .IR wiggle .
+This optimisation can be suppressed with the
+.B \-i
+flag.
 
 .IP 4
 If a change is found that does not fit any of the above possibilities,
index 975e39e4915f2e70628fb1d84c6600e7f145058d..f257898a8871a9fa6a7482d19d9cb0cf5c6703da 100644 (file)
--- a/wiggle.c
+++ b/wiggle.c
@@ -157,6 +157,7 @@ int main(int argc, char *argv[])
        int strip = -1;
        int chunks1=0, chunks2=0, chunks3=0;
        int exit_status = 0;
+       int ignore = 1;
        FILE *outfile = stdout;
        char *helpmsg;
        char *base0;
@@ -226,6 +227,10 @@ int main(int argc, char *argv[])
                        reverse = 1;
                        continue;
 
+               case 'i':
+                       ignore = 0;
+                       continue;
+
                case '1':
                case '2':
                case '3':
@@ -646,7 +651,8 @@ int main(int argc, char *argv[])
                        struct ci ci;
 
                        ci = print_merge2(outfile, &fl[0], &fl[1], &fl[2],
-                                                  csl1, csl2, obj=='w');
+                                         csl1, csl2, obj=='w',
+                                         ignore);
                        if (!quiet && ci.conflicts)
                                fprintf(stderr, "%d unresolved conflict%s found\n", ci.conflicts, ci.conflicts==1?"":"s");
                        if (!quiet && ci.ignored)
index ed8d87048d6af175f6e10a3d34ee70c379e92caa..9f7fa43ae5a959d4353870e7e36e61dfd970e9ca 100644 (file)
--- a/wiggle.h
+++ b/wiggle.h
@@ -121,12 +121,13 @@ extern struct ci print_merge(FILE *out, struct file *a, struct file *b, struct f
                       struct csl *c1, struct csl *c2,
                       int words);
 extern struct ci print_merge2(FILE *out, struct file *a, struct file *b, struct file *c,
-                      struct csl *c1, struct csl *c2,
-                      int words);
+                             struct csl *c1, struct csl *c2,
+                             int words, int ignore_already);
 extern void printword(FILE *f, struct elmnt e);
 
 extern struct ci make_merger(struct file a, struct file b, struct file c,
-                              struct csl *c1, struct csl *c2, int words);
+                            struct csl *c1, struct csl *c2, int words,
+                            int ignore_already);
 
 extern void die(void);