summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2018-06-19 17:02:27 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2018-06-20 14:29:38 +0100
commit8417abd83a6d2659bd556476ddee0a232d579eca (patch)
treed04f98bf4295c273884037b2f6c38a57180aebf0
parentda6f19f4f54e84723e9d1435bcfd4f7db8e55986 (diff)
git-debrebase: new-upstream: fix ff check handling of multi-piece upstreams
Multi-piece combine commits may have n or n+1 parents, depending on whether the previous new-upstream invocation was snag-free. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
-rw-r--r--debian/changelog2
-rwxr-xr-xgit-debrebase11
2 files changed, 9 insertions, 4 deletions
diff --git a/debian/changelog b/debian/changelog
index a70ec38..fc7aebb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,8 @@
dgit (5.1~) unstable; urgency=medium
* git-debrebase manpages: Fix typos and etc.
+ * git-debrebase: new-upstream: fix (this time for sure) ff check
+ handling of multi-piece upstreams.
--
diff --git a/git-debrebase b/git-debrebase
index 9e8d707..3458b12 100755
--- a/git-debrebase
+++ b/git-debrebase
@@ -1216,11 +1216,13 @@ sub cmd_new_upstream () {
) {
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 () {
$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 {