Skip to content

Commit c5e358d

Browse files
peffgitster
authored andcommitted
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 7acaaac (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 <[email protected]> Acked-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8530c73 commit c5e358d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sequencer.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,8 +2371,10 @@ int sequencer_pick_revisions(struct replay_opts *opts)
23712371
if (prepare_revision_walk(opts->revs))
23722372
return error(_("revision walk setup failed"));
23732373
cmit = get_revision(opts->revs);
2374-
if (!cmit || get_revision(opts->revs))
2375-
return error("BUG: expected exactly one commit from walk");
2374+
if (!cmit)
2375+
return error(_("empty commit set passed"));
2376+
if (get_revision(opts->revs))
2377+
BUG("unexpected extra commit from walk");
23762378
return single_pick(cmit, opts);
23772379
}
23782380

0 commit comments

Comments
 (0)