cherry-pick: do not error on non-merge commits when '-m 1' is specified
When cherry-picking multiple commits, it's impossible to have both merge- and non-merge commits on the same command-line. Not specifying '-m 1' results in cherry-pick refusing to handle merge commits, while specifying '-m 1' fails on non-merge commits. This patch allows '-m 1' for non-merge commits. As mainline is always the only parent for a non-merge commit, it makes little sense to disable it. Signed-off-by: Sergey Organov <sorganov@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Sergey Organov committed
Dec 14, 2018 at 07:53 UTC
37897bfc27d3003dddf7722113e676e925fe9e21
1 file changed
+7
-3
sequencer.c
+7
-3
@@ -1766,9 +1766,13 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
1766
return error(_("commit %s does not have parent %d"),
1767
oid_to_hex(&commit->object.oid), opts->mainline);
1768
parent = p->item;
1769
- } else if (0 < opts->mainline)
1770
- return error(_("mainline was specified but commit %s is not a merge."),
1771
- oid_to_hex(&commit->object.oid));
1769
+ } else if (1 < opts->mainline)
1770
+ /*
1771
+ * Non-first parent explicitly specified as mainline for
1772
+ * non-merge commit
1773
+ */
1774
+ return error(_("commit %s does not have parent %d"),
1775
+ oid_to_hex(&commit->object.oid), opts->mainline);
1776
else
1777
parent = commit->parents->item;
1778