chiark / gitweb /
git-debrebase: keycommits: Callbacks get separate $mainwhy
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 6 Jul 2018 23:13:02 +0000 (00:13 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 6 Jul 2018 23:13:02 +0000 (00:13 +0100)
Separate out the extra contextual info, naming the hash of the commit
being complained about, into a separate argument to $x->().  This
allows us to pass the message without that as an additional argument
to the callbacks.

This way we can still pass \&snag as a callback but other callers can
do something more sophisticated involving $cl.

No functional change for any existing callers.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
git-debrebase

index 04befff5484477c888825954b20ae53c760ce983..292471de90c33fc2e359a717d5a5ab5907eb56dd 100755 (executable)
@@ -568,11 +568,12 @@ sub keycommits ($;$$$$) {
     my $cl;
     $fatal //= sub { fail $_[2]; };
     my $x = sub {
-       my ($cb, $tagsfx, $why) = @_;
+       my ($cb, $tagsfx, $mainwhy, $xwhy) = @_;
+       my $why = $mainwhy.$xwhy;
        my $m = "branch needs laundering (run git-debrebase): $why";
        fail $m unless defined $cb;
        return unless $cb;
-       $cb->("unclean-$tagsfx", $why, $cl);
+       $cb->("unclean-$tagsfx", $why, $cl, $mainwhy);
     };
     for (;;) {
        $cl = classify $head;
@@ -593,27 +594,27 @@ sub keycommits ($;$$$$) {
            last;
        } elsif ($ty eq 'Upstream') {
            $x->($unclean, 'ordering',
- "packaging change ($breakwater) follows upstream change (eg $head)")
+ "packaging change ($breakwater) follows upstream change"," (eg $head)")
                if defined $breakwater;
            $clogonly = undef;
            $breakwater = undef;
        } elsif ($ty eq 'Mixed') {
            $x->($unclean, 'mixed',
-                "found mixed upstream/packaging commit ($head)");
+                "found mixed upstream/packaging commit"," ($head)");
            $clogonly = undef;
            $breakwater = undef;
        } elsif ($ty eq 'Pseudomerge' or
                 $ty eq 'AddPatches') {
            $x->($furniture, (lc $ty),
-                "found interchange bureaucracy commit ($ty$head)");
+                "found interchange bureaucracy commit ($ty)"," ($head)");
        } elsif ($ty eq 'DgitImportUnpatched') {
            $x->($trouble, 'dgitimport',
                 "found dgit dsc import ($head)");
            return (undef,undef);
        } else {
            $x->($fatal, 'unprocessable',
-                "found unprocessable commit, cannot cope: $head; $cl->{Why}"
-               );
+                "found unprocessable commit, cannot cope: $cl->{Why}",
+                " ($head)");
            return (undef,undef);
        }
        $head = $cl->{Parents}[0]{CommitId};