From: NeilBrown Date: Wed, 21 Aug 2013 02:17:34 +0000 (+1000) Subject: Add --report-wiggles option X-Git-Tag: v1.0~25 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=4382715f7176dc47e3b7ce21a58f68b887e9d4e8;p=wiggle.git Add --report-wiggles option This results in 'failure' status if any wiggles were required. Signed-off-by: NeilBrown --- diff --git a/ReadMe.c b/ReadMe.c index 255acd8..1db6f83 100644 --- a/ReadMe.c +++ b/ReadMe.c @@ -56,9 +56,10 @@ struct option long_options[] = { {"quiet", 0, 0, 'q'}, {"strip", 1, 0, 'p'}, {"no-ignore", 0, 0, 'i'}, - {"show-wiggle", 0, 0, 'W'}, + {"show-wiggles",0, 0, 'W'}, {"ignore-blanks",0,0, 'b'}, {"self-test", 0, 0, SELF_TEST}, + {"report-wiggles", 0, 0, REPORT_WIGGLES}, {0, 0, 0, 0} }; diff --git a/wiggle.1 b/wiggle.1 index 18591c7..5da108e 100644 --- a/wiggle.1 +++ b/wiggle.1 @@ -237,7 +237,7 @@ already have been applied in the original. With this flag those changes are reported as conflicts rather than being ignored. .TP -.BR -W ", " \-\-show\-wiggle +.BR -W ", " \-\-show\-wiggles When used with .IR \-\-merge , conflicts that can be wiggled into place are reported as conflicts @@ -262,6 +262,23 @@ Text that would result from a successful wiggle .fi .in -5 +.TP +.B \-\-report\-wiggles +If a merge is successful in applying all changes, it will normally exit +with a success status (0), only reporting failure (1) if a conflict +occurred and was annotated. With +.B \-\-report\-wiggles +.I wiggle +will also report failure if any changes had to be wiggled in. This +can be useful when +.I wiggle +is used for automatic merges as with +.IR git . +If any wiggles happen, +.I git +will report the failure, and the results can be examined to confirm +they are acceptable. + .TP .BR -h ", " \-\-help Print a simple help message. If given after one of the function @@ -355,6 +372,14 @@ If no errors occur (such as file access errors) will exit with a status of 0 if all changes were successfully merged, and with an exit status of 1 and a brief message if any changes could not be fully merged and were instead inserted as annotations. +However if either +.B \-\-report\-wiggles +or +.B \-\-show\-wiggles +options were given, +.I wiggle +will also exist with status of 1 if any changes had to be wiggled in +even though this was successful. The merge function can operate in three different modes with respect to lines or words. @@ -372,7 +397,7 @@ the \f(CW <<<|||===>>> \fP conflict format. Without either of these options, a hybrid approach is taken. Individual words are compared and merged, but when a conflict is found -the whole surrounding line is reported as being in conflict. +the whole surrounding line is reported as being in conflict. .I wiggle will ensure that every change between the two other texts is reflected diff --git a/wiggle.c b/wiggle.c index a9e9e0d..2cf6ac4 100644 --- a/wiggle.c +++ b/wiggle.c @@ -565,7 +565,7 @@ static int do_merge(int argc, char *argv[], int obj, int blanks, csl2 = diff_patch(fl[1], fl[2]); ci = make_merger(fl[0], fl[1], fl[2], csl1, csl2, - obj == 'w', ignore, show_wiggles); + obj == 'w', ignore, show_wiggles > 1); print_merge(outfile, &fl[0], &fl[1], &fl[2], obj == 'w', ci.merger); if (!quiet && ci.conflicts) @@ -591,7 +591,10 @@ static int do_merge(int argc, char *argv[], int obj, int blanks, return 2; } } - return (ci.conflicts > 0); + if (show_wiggles) + return ci.conflicts + ci.wiggles > 0; + else + return ci.conflicts > 0; } static int multi_merge(int argc, char *argv[], int obj, int blanks, @@ -739,9 +742,12 @@ int main(int argc, char *argv[]) ignore = 0; continue; case 'W': - show_wiggles = 1; + show_wiggles = 2; ignore = 0; continue; + case REPORT_WIGGLES: + show_wiggles = 1; + continue; case '1': case '2': diff --git a/wiggle.h b/wiggle.h index 2e9fb50..6560838 100644 --- a/wiggle.h +++ b/wiggle.h @@ -194,6 +194,7 @@ extern char short_options[]; extern struct option long_options[]; enum other_options { SELF_TEST = 300, + REPORT_WIGGLES = 301, }; extern char Usage[]; extern char Help[];