chiark / gitweb /
git-debrebase: keycommits: Now $fatal hook
[dgit.git] / git-debrebase
index 9a356df399f574da0c79bcb338e066f2b6708c61..c180a2946c28c50c10f806c54b7e7d922b99449f 100755 (executable)
@@ -538,8 +538,8 @@ sub classify ($) {
     return $unknown->("complex merge");
 }
 
-sub keycommits ($;$$$) {
-    my ($head, $furniture, $unclean, $trouble) = @_;
+sub keycommits ($;$$$$) {
+    my ($head, $furniture, $unclean, $trouble, $fatal) = @_;
     # => ($anchor, $breakwater)
 
     # $unclean->("unclean-$tagsfx", $msg, $cl)
@@ -552,6 +552,8 @@ sub keycommits ($;$$$) {
     # $trouble is for things whnich prevent the return of
     #   anchor and breakwater information; if that is ignored,
     #   then keycommits returns (undef, undef) instead.
+    # $fatal is for unprocessable commits, and should normally cause
+    #    a failure.  If ignored, agaion, (undef, undef) is returned.
     #
     # If a callback is undef, fail is called instead.
     # If a callback is defined but false, the situation is ignored.
@@ -562,6 +564,7 @@ sub keycommits ($;$$$) {
     my ($anchor, $breakwater);
     my $clogonly;
     my $cl;
+    $fatal //= sub { fail $_[2]; };
     my $x = sub {
        my ($cb, $tagsfx, $why) = @_;
        my $m = "branch needs laundering (run git-debrebase): $why";
@@ -606,7 +609,10 @@ sub keycommits ($;$$$) {
                 "found dgit dsc import ($head)");
            return (undef,undef);
        } else {
-           fail "found unprocessable commit, cannot cope: $head; $cl->{Why}";
+           $x->($fatal, 'unprocessable',
+                "found unprocessable commit, cannot cope: $head; $cl->{Why}"
+               );
+           return (undef,undef);
        }
        $head = $cl->{Parents}[0]{CommitId};
     }