Skip to content

Commit 0f974e2

Browse files
Michael J Grubergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Michael J Gruber <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7654286 commit 0f974e2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sequencer.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,10 @@ static int sequencer_rollback(struct replay_opts *opts)
919919
filename);
920920
goto fail;
921921
}
922+
if (is_null_sha1(sha1)) {
923+
error(_("cannot abort from a branch yet to be born"));
924+
goto fail;
925+
}
922926
if (reset_for_rollback(sha1))
923927
goto fail;
924928
remove_sequencer_state();
@@ -1118,11 +1122,8 @@ int sequencer_pick_revisions(struct replay_opts *opts)
11181122
walk_revs_populate_todo(&todo_list, opts);
11191123
if (create_seq_dir() < 0)
11201124
return -1;
1121-
if (get_sha1("HEAD", sha1)) {
1122-
if (opts->action == REPLAY_REVERT)
1123-
return error(_("Can't revert as initial commit"));
1124-
return error(_("Can't cherry-pick into empty head"));
1125-
}
1125+
if (get_sha1("HEAD", sha1) && (opts->action == REPLAY_REVERT))
1126+
return error(_("Can't revert as initial commit"));
11261127
save_head(sha1_to_hex(sha1));
11271128
save_opts(opts);
11281129
return pick_commits(todo_list, opts);

0 commit comments

Comments
 (0)