summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2018-07-24 14:50:48 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-07-24 14:50:48 -0700
commitd94cecfe7525606070163437f7c59a51650f9e56 (patch)
treec956ab875c2fd1109fd59c3a28c7033d789211ab
parentMerge branch 'bp/log-ref-write-fd-with-strbuf' (diff)
parentsequencer: don't say BUG on bogus input (diff)
downloadtgif-d94cecfe7525606070163437f7c59a51650f9e56.tar.xz
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
-rw-r--r--sequencer.c12
-rwxr-xr-xt/t3510-cherry-pick-sequence.sh7
2 files changed, 14 insertions, 5 deletions
diff --git a/sequencer.c b/sequencer.c
index 349ae04ffd..b89d5f2e34 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -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);
}
diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh
index b42cd66d3a..3505b6aa14 100755
--- a/t/t3510-cherry-pick-sequence.sh
+++ b/t/t3510-cherry-pick-sequence.sh
@@ -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 &&