{"thread":{"id":"66808","subject":"[PATCH] rev-parse, shortlog: accept --glob with a separate pattern","startedAt":"2026-11-09T05:24:02Z","lastAt":"2026-11-09T05:24:02Z","messageCount":1,"participants":["Laveesh Bansal"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"557873","messageId":"20261109052402.33604-1-laveeshb@laveeshbansal.com","threadId":"66808","inReplyTo":null,"subject":"[PATCH] rev-parse, shortlog: accept --glob with a separate pattern","fromName":"Laveesh Bansal","fromEmail":"laveeshb@laveeshbansal.com","sentAt":"2026-11-09T05:24:02Z","receivedAt":"2026-11-09T05:24:02Z","isPatch":true,"sender":{"key":"laveeshb@laveeshbansal.com","avatar":null},"body":"\"git log --glob <pattern>\" works, but the other two commands only\nunderstand \"--glob=<pattern>\":\n\n    $ git rev-parse --glob 'heads/*'\n    --glob\n    heads/*\n\n    $ git shortlog --glob 'heads/*'\n    error: unknown option `--glob'\n\n0fc63ec4e7 (revisions: allow --glob and friends in\nparse_options-enabled commands, 2011-04-21) only recognised the\n\"--glob=\" spelling for commands that parse options in two stages, and\n\"git rev-parse\" parses it by hand. Accept the separate word in both.\n\nThe four tests that commit added as known breakage now pass, so turn\nthem into regular tests.\n\nAssisted-by: LLM\nSigned-off-by: Laveesh Bansal <laveeshb@laveeshbansal.com>\n---\n\nNotes:\n    This only covers --glob. --exclude and --exclude-hidden have the same\n    gap and I will send them separately. --branches, --tags and --remotes\n    take an optional argument, so they stay in the \"=\" form.\n\n builtin/rev-parse.c      | 4 ++++\n revision.c               | 6 ++++++\n t/t6018-rev-list-glob.sh | 8 ++++----\n 3 files changed, 14 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex ec33c19bdf..c1ea7e81af 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -972,6 +972,10 @@ int cmd_rev_parse(int argc,\n \t\t\t\thandle_ref_opt(arg, NULL);\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(arg, \"--glob\") && i + 1 < argc) {\n+\t\t\t\thandle_ref_opt(argv[++i], NULL);\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tif (opt_with_value(arg, \"--remotes\", &arg)) {\n \t\t\t\tif (ref_excludes.hidden_refs_configured)\n \t\t\t\t\treturn error(_(\"options '%s' and '%s' cannot be used together\"),\ndiff --git a/revision.c b/revision.c\nindex a83e499047..df75c58bc7 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -2355,6 +2355,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \t/* pseudo revision arguments */\n+\tif (!strcmp(arg, \"--glob\") && argc > 1) {\n+\t\toverwrite_argv(unkc, unkv, &argv[0], opt, revs);\n+\t\toverwrite_argv(unkc, unkv, &argv[1], opt, revs);\n+\t\treturn 2;\n+\t}\n+\n \tif (!strcmp(arg, \"--all\") || !strcmp(arg, \"--branches\") ||\n \t    !strcmp(arg, \"--tags\") || !strcmp(arg, \"--remotes\") ||\n \t    !strcmp(arg, \"--reflog\") || !strcmp(arg, \"--not\") ||\ndiff --git a/t/t6018-rev-list-glob.sh b/t/t6018-rev-list-glob.sh\nindex bb55c7e3c3..01f064bc9e 100755\n--- a/t/t6018-rev-list-glob.sh\n+++ b/t/t6018-rev-list-glob.sh\n@@ -78,13 +78,13 @@ test_expect_success 'rev-parse --glob=heads/subspace' '\n \n '\n \n-test_expect_failure 'rev-parse accepts --glob as detached option' '\n+test_expect_success 'rev-parse accepts --glob as detached option' '\n \n \tcompare rev-parse \"subspace/one subspace/two\" \"--glob heads/subspace\"\n \n '\n \n-test_expect_failure 'rev-parse is not confused by option-like glob' '\n+test_expect_success 'rev-parse is not confused by option-like glob' '\n \n \tcompare rev-parse \"main\" \"--glob --symbolic main\"\n \n@@ -409,7 +409,7 @@ test_expect_success 'shortlog accepts --glob/--tags/--remotes' '\n \n '\n \n-test_expect_failure 'shortlog accepts --glob as detached option' '\n+test_expect_success 'shortlog accepts --glob as detached option' '\n \n \tcompare shortlog \\\n \t  \"main other/three someref subspace-x subspace/one subspace/two\" \\\n@@ -417,7 +417,7 @@ test_expect_failure 'shortlog accepts --glob as detached option' '\n \n '\n \n-test_expect_failure 'shortlog --glob is not confused by option-like argument' '\n+test_expect_success 'shortlog --glob is not confused by option-like argument' '\n \n \tcompare shortlog main \"--glob -e main\"\n \n-- \n2.54.0\n\n\n"}]}