Skip to content

Commit 37897bf

Browse files
sorganovgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c812bd4 commit 37897bf

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

sequencer.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,9 +1766,13 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
17661766
return error(_("commit %s does not have parent %d"),
17671767
oid_to_hex(&commit->object.oid), opts->mainline);
17681768
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);
17721776
else
17731777
parent = commit->parents->item;
17741778

0 commit comments

Comments
 (0)