summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2018-07-10 00:32:08 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-07-11 08:37:59 -0700
commitc5e358d07355080ea0f7a56f1edcc2f28879d9f4 (patch)
tree67392a0a6ccb2c170117bb1b2d47cac83cd824b5 /sequencer.c
parentsequencer: handle empty-set cases consistently (diff)
downloadtgif-c5e358d07355080ea0f7a56f1edcc2f28879d9f4.tar.xz
sequencer: don't say BUG on bogus input
When cherry-picking a single commit, we go through a special code path that avoids creating a sequencer todo list at all. This path expects our revision parsing to turn up exactly one commit, and dies with a BUG if it doesn't. But it's actually quite easy to fool. For example: $ git cherry-pick --author=no.such.person HEAD error: BUG: expected exactly one commit from walk fatal: cherry-pick failed This isn't a bug; it's just bogus input. The condition to trigger this message actually has two parts: 1. We saw no commits. That's the case in the example above. Let's drop the "BUG" here to make it clear that the input is the problem. And let's also use the phrase "empty commit set passed", which matches what we say when we do a real revision walk and it turns up empty. 2. We saw more than one commit. That one _should_ be impossible to trigger, since we fed at most one tip and provided the no_walk option (and we'll have already expanded options like "--branches" that can turn into multiple tips). If this ever triggers, it's an indication that the conditional added by 7acaaac275 (revert: allow single-pick in the middle of cherry-pick sequence, 2011-12-10) needs to more carefully define the single-pick case. So this can remain a bug, but we'll upgrade it to use the BUG() macro, which would make it easier to detect and analyze if it does trigger. Signed-off-by: Jeff King <peff@peff.net> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sequencer.c b/sequencer.c
index 7fbacc1021..5bf91b18e2 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -2371,8 +2371,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);
}