summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-01-18 21:49:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-01-18 21:49:54 (GMT)
commit77fbd96aebf794bc9131bd175be500eac2edcd2d (patch)
tree8edae0494b03edaa5d9626996356eb9515653284 /sequencer.c
parent726f89c2dd9c909f990eedf65d2519a043e5ad03 (diff)
parent1c320135e12c41d0f1ced7bd119c7ae0b65f307e (diff)
downloadgit-77fbd96aebf794bc9131bd175be500eac2edcd2d.zip
git-77fbd96aebf794bc9131bd175be500eac2edcd2d.tar.gz
git-77fbd96aebf794bc9131bd175be500eac2edcd2d.tar.bz2
Merge branch 'so/cherry-pick-always-allow-m1'
"git cherry-pick -m1" was forbidden when picking a non-merge commit, even though there _is_ parent number 1 for such a commit. This was done to avoid mistakes back when "cherry-pick" was about picking a single commit, but is no longer useful with "cherry-pick" that can pick a range of commits. Now the "-m$num" option is allowed when picking any commit, as long as $num names an existing parent of the commit. Technically this is a backward incompatible change; hopefully nobody is relying on the error-checking behaviour. * so/cherry-pick-always-allow-m1: t3506: validate '-m 1 -ff' is now accepted for non-merge commits t3502: validate '-m 1' argument is now accepted for non-merge commits cherry-pick: do not error on non-merge commits when '-m 1' is specified t3510: stop using '-m 1' to force failure mid-sequence of cherry-picks
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sequencer.c b/sequencer.c
index 4f1cb5e..f5370f4 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1790,9 +1790,13 @@ static int do_pick_commit(struct repository *r,
return error(_("commit %s does not have parent %d"),
oid_to_hex(&commit->object.oid), opts->mainline);
parent = p->item;
- } else if (0 < opts->mainline)
- return error(_("mainline was specified but commit %s is not a merge."),
- oid_to_hex(&commit->object.oid));
+ } else if (1 < opts->mainline)
+ /*
+ * Non-first parent explicitly specified as mainline for
+ * non-merge commit
+ */
+ return error(_("commit %s does not have parent %d"),
+ oid_to_hex(&commit->object.oid), opts->mainline);
else
parent = commit->parents->item;