Merge branch 'jk/empty-pick-fix'

Handling of an empty range by "git cherry-pick" was inconsistent
depending on how the range ended up to be empty, which has been
corrected.

* jk/empty-pick-fix:
  sequencer: don't say BUG on bogus input
  sequencer: handle empty-set cases consistently
This commit is contained in:
Junio C Hamano 2018-07-24 14:50:48 -07:00
commit d94cecfe75
2 changed files with 14 additions and 5 deletions

View file

@ -1864,8 +1864,6 @@ static int prepare_revs(struct replay_opts *opts)
if (prepare_revision_walk(opts->revs))
return error(_("revision walk setup failed"));
if (!opts->revs->commits)
return error(_("empty commit set passed"));
return 0;
}
@ -2323,6 +2321,10 @@ static int walk_revs_populate_todo(struct todo_list *todo_list,
short_commit_name(commit), subject_len, subject);
unuse_commit_buffer(commit, commit_buffer);
}
if (!todo_list->nr)
return error(_("empty commit set passed"));
return 0;
}
@ -3658,8 +3660,10 @@ int sequencer_pick_revisions(struct replay_opts *opts)
if (prepare_revision_walk(opts->revs))
return error(_("revision walk setup failed"));
cmit = get_revision(opts->revs);
if (!cmit || get_revision(opts->revs))
return error("BUG: expected exactly one commit from walk");
if (!cmit)
return error(_("empty commit set passed"));
if (get_revision(opts->revs))
BUG("unexpected extra commit from walk");
return single_pick(cmit, opts);
}

View file

@ -480,11 +480,16 @@ test_expect_success 'malformed instruction sheet 2' '
test_expect_code 128 git cherry-pick --continue
'
test_expect_success 'empty commit set' '
test_expect_success 'empty commit set (no commits to walk)' '
pristine_detach initial &&
test_expect_code 128 git cherry-pick base..base
'
test_expect_success 'empty commit set (culled during walk)' '
pristine_detach initial &&
test_expect_code 128 git cherry-pick -2 --author=no.such.author base
'
test_expect_success 'malformed instruction sheet 3' '
pristine_detach initial &&
test_expect_code 1 git cherry-pick base..anotherpick &&