From: Patrick Steinhardt <ps@pks.im>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 07/17] refs: speed up `refs_for_each_glob_ref_in()`
Date: Mon, 23 Feb 2026 11:48:03 +0100 [thread overview]
Message-ID: <aZwwYynerY8Yauqc@pks.im> (raw)
In-Reply-To: <CAOLa=ZRogQCpsD5eXOQrgt_DvgsXNfagbaxQm2eL+NwfUpw9OQ@mail.gmail.com>
On Mon, Feb 23, 2026 at 12:27:15AM -0800, Karthik Nayak wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> > diff --git a/refs.c b/refs.c
> > index ec9e466381..ac34bbe6c1 100644
> > --- a/refs.c
> > +++ b/refs.c
> > @@ -1862,16 +1845,44 @@ int refs_for_each_ref_ext(struct ref_store *refs,
> > refs_for_each_cb cb, void *cb_data,
> > const struct refs_for_each_ref_options *opts)
> > {
> > + struct strbuf real_pattern = STRBUF_INIT;
> > + struct for_each_ref_filter filter;
> > struct ref_iterator *iter;
> > + int ret;
> >
> > if (!refs)
> > return 0;
> >
> > + if (opts->pattern) {
> > + if (!opts->prefix && !starts_with(opts->pattern, "refs/"))
> > + strbuf_addstr(&real_pattern, "refs/");
> > + else if (opts->prefix)
> > + strbuf_addstr(&real_pattern, opts->prefix);
> > + strbuf_addstr(&real_pattern, opts->pattern);
> > +
> > + if (!has_glob_specials(opts->pattern)) {
> > + /* Append implied '/' '*' if not present. */
> > + strbuf_complete(&real_pattern, '/');
> > + /* No need to check for '*', there is none. */
> > + strbuf_addch(&real_pattern, '*');
> > + }
> > +
> > + filter.pattern = real_pattern.buf;
> > + filter.prefix = opts->prefix;
>
> Can't we now remove this option and cleanup `for_each_filter_refs()` to
> remove prefix trimming?
No, unfortunately not. This is because the glob pattern is expected to
match on the full refname, so if we were to strip the refname before we
pass it to the `filter` callback then we wouldn't be able to do the call
to wildmatch anymore.
But the stripping part is still a bit funky after my refactoring, as we
unconditionall strip the prefix right now. This is the expected
behaviour, but it is somewhat surprising I guess. I'll rework this part
a bit, thanks!
Patrick
next prev parent reply other threads:[~2026-02-23 10:48 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-20 8:24 [PATCH 00/17] refs: unify `refs_for_each_*()` functions Patrick Steinhardt
2026-02-20 8:24 ` [PATCH 01/17] refs: move `refs_head_ref_namespaced()` Patrick Steinhardt
2026-02-23 8:05 ` Karthik Nayak
2026-02-23 10:46 ` Patrick Steinhardt
2026-02-20 8:24 ` [PATCH 02/17] refs: move `do_for_each_ref_flags` further up Patrick Steinhardt
2026-02-20 8:24 ` [PATCH 03/17] refs: rename `do_for_each_ref_flags` Patrick Steinhardt
2026-02-20 8:24 ` [PATCH 04/17] refs: rename `each_ref_fn` Patrick Steinhardt
2026-02-23 8:07 ` Karthik Nayak
2026-02-20 8:24 ` [PATCH 05/17] refs: remove unused `refs_for_each_include_root_ref()` Patrick Steinhardt
2026-02-20 10:29 ` Oswald Buddenhagen
2026-02-20 12:05 ` Patrick Steinhardt
2026-02-20 8:24 ` [PATCH 06/17] refs: introduce `refs_for_each_ref_ext` Patrick Steinhardt
2026-02-23 8:14 ` Karthik Nayak
2026-02-20 8:24 ` [PATCH 07/17] refs: speed up `refs_for_each_glob_ref_in()` Patrick Steinhardt
2026-02-23 8:27 ` Karthik Nayak
2026-02-23 10:48 ` Patrick Steinhardt [this message]
2026-02-20 8:24 ` [PATCH 08/17] refs: generalize `refs_for_each_namespaced_ref()` Patrick Steinhardt
2026-02-23 9:02 ` Karthik Nayak
2026-02-23 10:48 ` Patrick Steinhardt
2026-02-20 8:24 ` [PATCH 09/17] refs: generalize `refs_for_each_fullref_in_prefixes()` Patrick Steinhardt
2026-02-23 9:06 ` Karthik Nayak
2026-02-20 8:24 ` [PATCH 10/17] refs: improve verification for-each-ref options Patrick Steinhardt
2026-02-23 9:09 ` Karthik Nayak
2026-02-20 8:24 ` [PATCH 11/17] refs: replace `refs_for_each_ref_in()` Patrick Steinhardt
2026-02-23 9:11 ` Karthik Nayak
2026-02-23 10:48 ` Patrick Steinhardt
2026-02-23 13:35 ` Karthik Nayak
2026-02-20 8:24 ` [PATCH 12/17] refs: replace `refs_for_each_rawref()` Patrick Steinhardt
2026-02-20 8:24 ` [PATCH 13/17] refs: replace `refs_for_each_rawref_in()` Patrick Steinhardt
2026-02-20 8:24 ` [PATCH 14/17] refs: replace `refs_for_each_glob_ref_in()` Patrick Steinhardt
2026-02-20 8:24 ` [PATCH 15/17] refs: replace `refs_for_each_glob_ref()` Patrick Steinhardt
2026-02-20 8:24 ` [PATCH 16/17] refs: replace `refs_for_each_namespaced_ref()` Patrick Steinhardt
2026-02-20 8:24 ` [PATCH 17/17] refs: replace `refs_for_each_fullref_in()` Patrick Steinhardt
2026-02-23 9:14 ` [PATCH 00/17] refs: unify `refs_for_each_*()` functions Karthik Nayak
2026-02-23 11:59 ` [PATCH v2 " Patrick Steinhardt
2026-02-23 11:59 ` [PATCH v2 01/17] refs: remove unused `refs_for_each_include_root_ref()` Patrick Steinhardt
2026-02-23 11:59 ` [PATCH v2 02/17] refs: move `refs_head_ref_namespaced()` Patrick Steinhardt
2026-02-23 11:59 ` [PATCH v2 03/17] refs: move `do_for_each_ref_flags` further up Patrick Steinhardt
2026-02-23 11:59 ` [PATCH v2 04/17] refs: rename `do_for_each_ref_flags` Patrick Steinhardt
2026-02-23 11:59 ` [PATCH v2 05/17] refs: rename `each_ref_fn` Patrick Steinhardt
2026-02-23 11:59 ` [PATCH v2 06/17] refs: introduce `refs_for_each_ref_ext` Patrick Steinhardt
2026-02-23 11:59 ` [PATCH v2 07/17] refs: speed up `refs_for_each_glob_ref_in()` Patrick Steinhardt
2026-02-23 11:59 ` [PATCH v2 08/17] refs: generalize `refs_for_each_namespaced_ref()` Patrick Steinhardt
2026-02-23 11:59 ` [PATCH v2 09/17] refs: generalize `refs_for_each_fullref_in_prefixes()` Patrick Steinhardt
2026-02-23 11:59 ` [PATCH v2 10/17] refs: improve verification for-each-ref options Patrick Steinhardt
2026-02-23 11:59 ` [PATCH v2 11/17] refs: replace `refs_for_each_ref_in()` Patrick Steinhardt
2026-02-23 11:59 ` [PATCH v2 12/17] refs: replace `refs_for_each_rawref()` Patrick Steinhardt
2026-02-23 11:59 ` [PATCH v2 13/17] refs: replace `refs_for_each_rawref_in()` Patrick Steinhardt
2026-02-23 11:59 ` [PATCH v2 14/17] refs: replace `refs_for_each_glob_ref_in()` Patrick Steinhardt
2026-02-23 11:59 ` [PATCH v2 15/17] refs: replace `refs_for_each_glob_ref()` Patrick Steinhardt
2026-02-23 11:59 ` [PATCH v2 16/17] refs: replace `refs_for_each_namespaced_ref()` Patrick Steinhardt
2026-02-23 11:59 ` [PATCH v2 17/17] refs: replace `refs_for_each_fullref_in()` Patrick Steinhardt
2026-02-24 13:14 ` [PATCH v2 00/17] refs: unify `refs_for_each_*()` functions Karthik Nayak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aZwwYynerY8Yauqc@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=karthik.188@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox