]> git.neil.brown.name Git - wiggle.git/commitdiff
Add --report-wiggles option
authorNeilBrown <neilb@suse.de>
Wed, 21 Aug 2013 02:17:34 +0000 (12:17 +1000)
committerNeilBrown <neilb@suse.de>
Wed, 21 Aug 2013 02:17:34 +0000 (12:17 +1000)
This results in 'failure' status if any wiggles were required.

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

index 255acd8c34ab6fc95ff8f2ebe4702804cc4bd7d5..1db6f83f3eeb1acd0e5f0a5af5bbb7a78e7db47d 100644 (file)
--- 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}
 };
 
index 18591c7e9ae7ddf4d07517555757c3027d7c126e..5da108ed6c1941ec3ebc65e2d69de1c3f2aa83bb 100644 (file)
--- 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
index a9e9e0d0a30ad7d87acd07ed89f5a49623b42294..2cf6ac434ffbd709ab1e1bad31206fb5cd1cf6f7 100644 (file)
--- 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':
index 2e9fb50908ea697e22c8f4892ec1097b36bc57f8..656083844376e61d35837f39a933d49beda69e58 100644 (file)
--- 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[];