Skip to content

Commit 25227f0

Browse files
committed
Merge branch 'mg/cherry-pick-multi-on-unborn' into maint
"git cherry-pick A" worked on an unborn branch, but "git cherry-pick A..B" didn't. * mg/cherry-pick-multi-on-unborn: cherry-pick: allow to pick to unborn branches
2 parents af3a43c + 0f974e2 commit 25227f0

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
@@ -888,6 +888,10 @@ static int sequencer_rollback(struct replay_opts *opts)
888888
git_path_head_file());
889889
goto fail;
890890
}
891+
if (is_null_sha1(sha1)) {
892+
error(_("cannot abort from a branch yet to be born"));
893+
goto fail;
894+
}
891895
if (reset_for_rollback(sha1))
892896
goto fail;
893897
remove_sequencer_state();
@@ -1086,11 +1090,8 @@ int sequencer_pick_revisions(struct replay_opts *opts)
10861090
walk_revs_populate_todo(&todo_list, opts);
10871091
if (create_seq_dir() < 0)
10881092
return -1;
1089-
if (get_sha1("HEAD", sha1)) {
1090-
if (opts->action == REPLAY_REVERT)
1091-
return error(_("Can't revert as initial commit"));
1092-
return error(_("Can't cherry-pick into empty head"));
1093-
}
1093+
if (get_sha1("HEAD", sha1) && (opts->action == REPLAY_REVERT))
1094+
return error(_("Can't revert as initial commit"));
10941095
save_head(sha1_to_hex(sha1));
10951096
save_opts(opts);
10961097
return pick_commits(todo_list, opts);

0 commit comments

Comments
 (0)