git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] sequencer: don't say BUG on bogus input

From
Jeff King <peff@peff.net>
Date
Jul 9, 2018, 19:49 UTC
Message-ID
<20180709194912.GB7980@sigill.intra.peff.net>
In-Reply-To
<20180709194636.GB9852@sigill.intra.peff.net>

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.

Let's drop the "BUG" 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.

This BUG dates back to 7acaaac275 (revert: allow single-pick in the middle of cherry-pick sequence, 2011-12-10), and could be triggered in the same way even then. So clearly this outcome is unexpected. Another approach would be to make the conditional from 7acaaac275 smarter, and avoid even entering this single-pick case. But since the action is identical either way (we have nothing to pick, so we exit) there's not much point in trying to distinguish the two.

Signed-off-by: Jeff King <peff@peff.net>
---
 sequencer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sequencer.c b/sequencer.c
index f692b2ef44..234666b980 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -3637,7 +3637,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)
 			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");
+			return error(_("empty commit set passed"));
 		return single_pick(cmit, opts);
 	}
 
-- 
2.18.0.400.g702e398724
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 7 of 15 in “[BUG] git cherry-pick does not complain about unknown options”
  1. Andrei RybakJul 9, 2018
  2. Jeff KingJul 9, 2018
  3. 0/2 de-confuse git cherry-pick --author behaviorJeff King, Jul 9, 2018
  4. 1/2 sequencer: handle empty-set cases consistentlyJeff King, Jul 9, 2018
  5. Junio C HamanoJul 9, 2018
  6. Johannes SchindelinJul 9, 2018
  7. 2/2 sequencer: don't say BUG on bogus inputJeff King, Jul 9, 2018
  8. Johannes SchindelinJul 9, 2018
  9. Junio C HamanoJul 9, 2018
  10. Jeff KingJul 10, 2018
  11. 0/2 de-confuse git cherry-pick --authorJeff King, Jul 10, 2018
  12. 1/2 sequencer: handle empty-set cases consistentlyJeff King, Jul 10, 2018
  13. 2/2 sequencer: don't say BUG on bogus inputJeff King, Jul 10, 2018
  14. Johannes SchindelinJul 11, 2018
  15. Junio C HamanoJul 11, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.