chiark / gitweb /
dgit: gitattributes: Defuse working-tree-encoding
[dgit.git] / git-debrebase
index 216d7dfa150e9018a488839d07a9c60341d7313b..3458b12f5d86d93c2de804989afbed423cc43e92 100755 (executable)
@@ -1129,7 +1129,7 @@ sub do_stitch ($;$) {
     stitch($dangling_head, $ffq_prev, $gdrlast, $ffq_prev_commitish, $prose);
 }
 
-sub cmd_new_upstream_v0 () {
+sub cmd_new_upstream () {
     # automatically and unconditionally launders before rebasing
     # if rebase --abort is used, laundering has still been done
 
@@ -1216,11 +1216,13 @@ sub cmd_new_upstream_v0 () {
           ) {
            my @oldpieces = (split / /, $1);
            my $old_n_parents = scalar @{ $old_upstream->{Parents} };
-           if (@oldpieces != $old_n_parents) {
+           if ($old_n_parents != @oldpieces &&
+               $old_n_parents != @oldpieces + 1) {
                snag 'upstream-confusing', sprintf
                    "previous upstream combine %s".
-                   " mentions %d pieces (each implying one orig commit)".
-                   " but has %d parents",
+                   " mentions %d pieces (each implying one parent)".
+                   " but has %d parents".
+                   " (one per piece plus maybe a previous combine)",
                    $old_upstream->{CommitId},
                    (scalar @oldpieces),
                    $old_n_parents;
@@ -1233,7 +1235,8 @@ sub cmd_new_upstream_v0 () {
                $oldpieces[0] = '';
                foreach my $i (0..$#oldpieces) {
                    my $n = $oldpieces[$i];
-                   $piece->($n, Old => $old_upstream->{CommitId}.'^'.($i+1));
+                   my $hat = 1 + $i + ($old_n_parents - @oldpieces);
+                   $piece->($n, Old => $old_upstream->{CommitId}.'^'.$hat);
                }
            }
        } else {