{"thread":{"id":"48572","subject":"[PATCH] cherry-pick: do not error on non-merge commits when '-m 1' is specified","startedAt":"2018-05-25T12:47:42Z","lastAt":"2018-05-25T12:47:42Z","messageCount":1,"participants":["Sergey Organov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"348540","messageId":"87wovrx5yc.fsf@javad.com","threadId":"48572","inReplyTo":null,"subject":"[PATCH] cherry-pick: do not error on non-merge commits when '-m 1' is specified","fromName":"Sergey Organov","fromEmail":"sorganov@gmail.com","sentAt":"2018-05-25T12:42:03Z","receivedAt":"2018-05-25T12:47:42Z","isPatch":true,"sender":{"key":"sorganov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8501568?v=4"},"body":"When cherry-picking multiple commits, it's impossible to have both\nmerge- and non-merge commits on the same command-line. Not specifying\n'-m 1' results in cherry-pick refusing to handle merge commits, while\nspecifying '-m 1' fails on non-merge commits.\n\nThis patch allows '-m 1' for non-merge commits. Besides, as mainline is\nalways the only parent for a non-merge commit, it made little sense to\ndisable it in the first place.\n\nSigned-off-by: Sergey Organov <sorganov@gmail.com>\n---\n sequencer.c | 8 +++++---\n 1 file changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 1ce6326..2393bdf 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -1543,9 +1543,11 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\t\treturn error(_(\"commit %s does not have parent %d\"),\n \t\t\t\toid_to_hex(&commit->object.oid), opts->mainline);\n \t\tparent = p->item;\n-\t} else if (0 < opts->mainline)\n-\t\treturn error(_(\"mainline was specified but commit %s is not a merge.\"),\n-\t\t\toid_to_hex(&commit->object.oid));\n+\t} else if (1 < opts->mainline)\n+\t\t/* Non-first parent explicitly specified as mainline for\n+\t\t * non-merge commit */\n+\t\treturn error(_(\"commit %s does not have parent %d\"),\n+\t\t\t     oid_to_hex(&commit->object.oid), opts->mainline);\n \telse\n \t\tparent = commit->parents->item;\n \n-- \n2.10.0.1.g57b01a3\n\n"}]}