From: Neil Brown Date: Wed, 24 Mar 2010 08:03:39 +0000 (+1100) Subject: Add --no-ignore option X-Git-Tag: v0.8~1 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=3f524fcbe3626e5b760ebac76e978232fc64c79d;p=wiggle.git Add --no-ignore option This suppresses the optimisation of ignoring conflicts which appear to be making a change that had already been made. Signed-off-by: NeilBrown --- diff --git a/ReadMe.c b/ReadMe.c index fad1888..84c5c47 100644 --- 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} }; diff --git a/merge2.c b/merge2.c index 768baee..592157c 100644 --- 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++) { diff --git a/vpatch.c b/vpatch.c index 1813a3d..f336180 100644 --- 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 */ diff --git a/wiggle.1 b/wiggle.1 index c4f2a6e..8967b0c 100644 --- 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, diff --git a/wiggle.c b/wiggle.c index 975e39e..f257898 100644 --- 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) diff --git a/wiggle.h b/wiggle.h index ed8d870..9f7fa43 100644 --- 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);