Thread View: linux.kernel.git
2 messages
2 total messages
Started by Laveesh Bansal
Mon, 09 Nov 2026 05:24
[PATCH] rev-parse, shortlog: accept --glob with a separate pattern
Author: Laveesh Bansal
Date: Mon, 09 Nov 2026 05:24
Date: Mon, 09 Nov 2026 05:24
105 lines
12684 bytes
12684 bytes
"git log --glob <pattern>" works, but the other two commands only
understand "--glob=<pattern>":
$ git rev-parse --glob 'heads/*'
--glob
heads/*
$ git shortlog --glob 'heads/*'
error: unknown option `--glob'
0fc63ec4e7 (revisions: allow --glob and friends in
parse_options-enabled commands, 2011-04-21) only recognised the
"--glob=" spelling for commands that parse options in two stages, and
"git rev-parse" parses it by hand. Accept the separate word in both.
The four tests that commit added as known breakage now pass, so turn
them into regular tests.
Assisted-by: LLM
Signed-off-by: Laveesh Bansal <laveeshb@laveeshbansal.com>
---
Notes:
This only covers --glob. --exclude and --exclude-hidden have the same
gap and I will send them separately. --branches, --tags and --remotes
take an optional argument, so they stay in the "=" form.
builtin/rev-parse.c | 4 ++++
revision.c | 6 ++++++
t/t6018-rev-list-glob.sh | 8 ++++----
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index ec33c19bdf..c1ea7e81af 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -972,6 +972,10 @@ int cmd_rev_parse(int argc,
handle_ref_opt(arg, NULL);
continue;
}
+ if (!strcmp(arg, "--glob") && i + 1 < argc) {
+ handle_ref_opt(argv[++i], NULL);
+ continue;
+ }
if (opt_with_value(arg, "--remotes", &arg)) {
if (ref_excludes.hidden_refs_configured)
return error(_("options '%s' and '%s' cannot be used together"),
diff --git a/revision.c b/revision.c
index a83e499047..df75c58bc7 100644
--- a/revision.c
+++ b/revision.c
@@ -2355,6 +2355,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
const unsigned hexsz = the_hash_algo->hexsz;
/* pseudo revision arguments */
+ if (!strcmp(arg, "--glob") && argc > 1) {
+ overwrite_argv(unkc, unkv, &argv[0], opt, revs);
+ overwrite_argv(unkc, unkv, &argv[1], opt, revs);
+ return 2;
+ }
+
if (!strcmp(arg, "--all") || !strcmp(arg, "--branches") ||
!strcmp(arg, "--tags") || !strcmp(arg, "--remotes") ||
!strcmp(arg, "--reflog") || !strcmp(arg, "--not") ||
diff --git a/t/t6018-rev-list-glob.sh b/t/t6018-rev-list-glob.sh
index bb55c7e3c3..01f064bc9e 100755
--- a/t/t6018-rev-list-glob.sh
+++ b/t/t6018-rev-list-glob.sh
@@ -78,13 +78,13 @@ test_expect_success 'rev-parse --glob=heads/subspace' '
'
-test_expect_failure 'rev-parse accepts --glob as detached option' '
+test_expect_success 'rev-parse accepts --glob as detached option' '
compare rev-parse "subspace/one subspace/two" "--glob heads/subspace"
'
-test_expect_failure 'rev-parse is not confused by option-like glob' '
+test_expect_success 'rev-parse is not confused by option-like glob' '
compare rev-parse "main" "--glob --symbolic main"
@@ -409,7 +409,7 @@ test_expect_success 'shortlog accepts --glob/--tags/--remotes' '
'
-test_expect_failure 'shortlog accepts --glob as detached option' '
+test_expect_success 'shortlog accepts --glob as detached option' '
compare shortlog \
"main other/three someref subspace-x subspace/one subspace/two" \
@@ -417,7 +417,7 @@ test_expect_failure 'shortlog accepts --glob as detached option' '
'
-test_expect_failure 'shortlog --glob is not confused by option-like argument' '
+test_expect_success 'shortlog --glob is not confused by option-like argument' '
compare shortlog main "--glob -e main"
--
2.54.0
Re: [PATCH] rev-parse, shortlog: accept --glob with a separate pattern
Author: Laveesh Bansal
Date: Mon, 23 Nov 2026 16:59
Date: Mon, 23 Nov 2026 16:59
18 lines
9922 bytes
9922 bytes
Hi, A gentle ping on this patch. It has been about two weeks since I sent it, and I wanted to check that it had not slipped through. It still applies to current master (f7de814569) without conflicts, and t6018 passes with it. In short: "git log" accepts "--glob <pattern>" as two words, but "git rev-parse" and "git shortlog" only understand "--glob=<pattern>". The patch makes them accept both forms, which turns the four known-breakage tests in t6018 into regular ones. If this looks reasonable, I will send --exclude and --exclude-hidden as a follow-up. Thanks, Laveesh
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads