chiark / gitweb /
git-debrebase: merge: Generate some more debugging commits
[dgit.git] / git-debrebase
index 06cdc7692ccdeeeb367b6ec244afc742ff004840..ef619be4d1141f3cc7aa3d9884538ad9cf34841e 100755 (executable)
@@ -529,6 +529,13 @@ sub merge_series ($$;@) {
        }
        $result = $build;
        runcmd @git, qw(update-ref refs/heads/result), $result;
+
+       runcmd @git, qw(checkout -q -b debug);
+       runcmd @git, qw(commit --allow-empty -q -m M-INDEX);
+       runcmd @git, qw(add .);
+       runcmd @git, qw(commit --allow-empty -q -m M-WORKTREE);
+       printdebug sprintf "merge_series done debug=%s\n",
+           git_rev_parse 'HEAD';
     };
     printdebug "merge_series returns $result\n";
     return $result;
@@ -810,8 +817,23 @@ sub classify ($) {
     return $classify->("VanillaMerge");
 }
 
-sub keycommits ($;$$$$) {
-    my ($head, $furniture, $unclean, $trouble, $fatal) = @_;
+sub keycommits ($;$$$$$);
+
+sub mergedbreakwaters_anchor ($) {
+    my ($cl) = @_;
+    my $best_anchor;
+    foreach my $p (@{ $cl->{Parents} }) {
+       my ($panchor, $pbw) = keycommits $p->{CommitId},
+           undef,undef,undef,undef, 1;
+       $best_anchor = $panchor
+           if !defined $best_anchor
+           or is_fast_fwd $best_anchor, $panchor;
+    }
+    return $best_anchor;
+}
+
+sub keycommits ($;$$$$$) {
+    my ($head, $furniture, $unclean, $trouble, $fatal, $claimed_bw) = @_;
     # => ($anchor, $breakwater)
 
     # $unclean->("unclean-$tagsfx", $msg, $cl)
@@ -827,6 +849,8 @@ sub keycommits ($;$$$$) {
     # $fatal is for unprocessable commits, and should normally cause
     #    a failure.  If ignored, agaion, (undef, undef) is returned.
     #
+    # If $claimed_bw, this is supposed to be a breakwater commit.
+    #
     # If a callback is undef, fail is called instead.
     # If a callback is defined but false, the situation is ignored.
     # Callbacks may say:
@@ -834,6 +858,7 @@ sub keycommits ($;$$$$) {
     # if the answer is no longer wanted.
 
     my ($anchor, $breakwater);
+    $breakwater = $head if $claimed_bw;
     my $clogonly;
     my $cl;
     my $found_pm;
@@ -898,6 +923,8 @@ sub keycommits ($;$$$$) {
            $x->($trouble, 'vanillamerge',
                 "found vanilla merge"," ($head)");
            return (undef,undef);
+       } elsif ($ty eq 'MergedBreakwaters') {
+           $found_anchor->(mergedbreakwaters_anchor $cl);
        } else {
            $x->($fatal, 'unprocessable',
                 "found unprocessable commit, cannot cope: $cl->{Why}",
@@ -1219,7 +1246,8 @@ sub walk ($;$$$) {
            push @brw_cl, {
                 %$cl,
                 SpecialMethod => 'MergeCreateMergedBreakwaters',
-                $xmsg->('construct merged breakwater from vanilla merge'),
+                $xmsg->('constructed from vanilla merge',
+                       ' merged-breakwater'),
             };
            push @upp_cl, {
                 %$cl,