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

[PATCH v2] rev-list: skip --grep argument in early scan

From
AMAzuama Odinaka Maximus <azuama69@gmail.com>
Date
Oct 21, 2026, 17:24 UTC
Message-ID
<20261021172458.6373-1-azuama69@gmail.com>
In-Reply-To
<20261021151253.3689-1-azuama69@gmail.com>

The early option scan in rev-list does not account for options that take a separate argument. As a result, a pattern passed to --grep can be mistaken for another option.

Skip the argument to --grep so that it is not interpreted as an
option during the early scan.
---
 builtin/rev-list.c          |  2 ++
 t/t6022-rev-list-missing.sh | 11 +++++++++++
 2 files changed, 13 insertions(+)
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 0faa833fac..453d82d25c 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -771,6 +771,8 @@ int cmd_rev_list(int argc,
 			revs.exclude_promisor_objects = 1;
 		} else if (skip_prefix(arg, "--missing=", &arg)) {
 			parse_missing_action_value(repo, arg);
+		} else if (!strcmp(arg, "--grep")) {
+			i++;
 		} else if (!strcmp(arg, "--missing-only")) {
 			arg_missing_only = 1;
 		} else if (!strcmp(arg, "-z")) {
diff --git a/t/t6022-rev-list-missing.sh b/t/t6022-rev-list-missing.sh
index 1bd2c3bc4f..180e6ac766 100755
--- a/t/t6022-rev-list-missing.sh
+++ b/t/t6022-rev-list-missing.sh
@@ -215,6 +215,17 @@ do
 	'
 done
 
+test_expect_success "--grep accepts a pattern beginning with --" '
+	git rev-list --grep=--missing-only --max-count=1 HEAD >expect &&
+	git rev-list --grep --missing-only --max-count=1 HEAD >actual &&
+	test_cmp expect actual
+'
+test_expect_success "--grep does not trigger --exclude-promisor-objects in early scan" '
+    git rev-list --grep=--exclude-promisor-objects --missing=print HEAD >expect &&
+    git rev-list --grep --exclude-promisor-objects --missing=print HEAD >actual &&
+    test_cmp expect actual
+'
+
 test_expect_success "--missing-only requires --missing=print or --missing=print-info" '
 	test_must_fail git rev-list --missing-only --objects HEAD 2>err &&
 	test_grep "requires --missing=print" err
-- 
2.53.0
Previous: Pushkar SinghNext: Pushkar Singh
Message 3 of 11 in “rev-list: skip --grep argument in early scan”
  1. rev-list: skip --grep argument in early scanAzuama Odinaka Maximus, Oct 21, 2026
  2. Pushkar SinghOct 21, 2026
  3. rev-list: skip --grep argument in early scanAzuama Odinaka Maximus, Oct 21, 2026
  4. Pushkar SinghOct 22, 2026
  5. Junio C HamanoOct 23, 2026
  6. rev-list: skip --grep argument in early scanAzuama Odinaka Maximus, Oct 26, 2026
  7. Tanga JorisNov 5, 2026
  8. rev-list: handle arguments in early option scanAzuama Odinaka Maximus, Nov 5, 2026
  9. Junio C HamanoNov 6, 2026
  10. Azuama Odinaka MaximusNov 6, 2026
  11. Junio C HamanoNov 6, 2026

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.