1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-28 04:36:10 +02:00

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 <fabrizio.cucci@gmail.com>
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Michael J Gruber 2016-06-06 15:23:54 +02:00 committed by Junio C Hamano
parent 765428699a
commit 0f974e2124

View File

@ -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);