From 0f974e2124e5220674eee079988b87e23f5e2de1 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Mon, 6 Jun 2016 15:23:54 +0200 Subject: cherry-pick: allow to pick to unborn branches cherry-pick allows to pick single commits to an empty HEAD, but not multiple commits. Allow the multiple commit case, too. Reported-by: Fabrizio Cucci Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano diff --git a/sequencer.c b/sequencer.c index c4f4b7d..c051d13 100644 --- a/sequencer.c +++ b/sequencer.c @@ -919,6 +919,10 @@ static int sequencer_rollback(struct replay_opts *opts) filename); goto fail; } + if (is_null_sha1(sha1)) { + error(_("cannot abort from a branch yet to be born")); + goto fail; + } if (reset_for_rollback(sha1)) goto fail; remove_sequencer_state(); @@ -1118,11 +1122,8 @@ int sequencer_pick_revisions(struct replay_opts *opts) walk_revs_populate_todo(&todo_list, opts); if (create_seq_dir() < 0) return -1; - if (get_sha1("HEAD", sha1)) { - if (opts->action == REPLAY_REVERT) - return error(_("Can't revert as initial commit")); - return error(_("Can't cherry-pick into empty head")); - } + if (get_sha1("HEAD", sha1) && (opts->action == REPLAY_REVERT)) + return error(_("Can't revert as initial commit")); save_head(sha1_to_hex(sha1)); save_opts(opts); return pick_commits(todo_list, opts); -- cgit v0.10.2-6-g49f6