From 39e84f67e266f87368e4bce44d4b4b469ef7165a Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 16 Jun 2018 20:41:23 +0100 Subject: git-debrebase: keycommits: Now $fatal hook This allows a caller to avoid having keycommits crash on unrecognisable stuff. This will be used in a moment. No functional change, because the default implementation calls fail the same way it did before. Signed-off-by: Ian Jackson --- git-debrebase | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/git-debrebase b/git-debrebase index 9a356df..c180a29 100755 --- a/git-debrebase +++ b/git-debrebase @@ -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}; } -- cgit v1.2.3