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

[PATCH] cherry-pick: do not segfault without arguments.

From
Stefan Beller <stefanbeller@googlemail.com>
Date
Oct 4, 2013, 14:09 UTC
Message-ID
<1380895752-5286-1-git-send-email-stefanbeller@googlemail.com>

Commit 182d7dc46b (2013-09-05, cherry-pick: allow "-" as abbreviation of '@{-1}') accesses the first argument without checking whether it exists.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
---
 builtin/revert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/revert.c b/builtin/revert.c
index 52c35e7..f81a48c 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -202,7 +202,7 @@ int cmd_cherry_pick(int argc, const char **argv, const char *prefix)
 	memset(&opts, 0, sizeof(opts));
 	opts.action = REPLAY_PICK;
 	git_config(git_default_config, NULL);
-	if (!strcmp(argv[1], "-"))
+	if (argc > 1 && !strcmp(argv[1], "-"))
 		argv[1] = "@{-1}";
 	parse_args(argc, argv, &opts);
 	res = sequencer_pick_revisions(&opts);
-- 
1.8.4.1.469.gb38b9db
Next: Jeff King
Message 1 of 3 in “cherry-pick: do not segfault without arguments.”
  1. cherry-pick: do not segfault without arguments.Stefan Beller, Oct 4, 2013
  2. Jeff KingOct 10, 2013
  3. Stefan BellerOct 10, 2013

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.