Re: [PATCH 11/17] refs: replace `refs_for_each_ref_in()`
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Feb 23, 2026, 10:48 UTC
- Message-ID
- <aZwwchZjnSMTiN0m@pks.im>
- In-Reply-To
- <CAOLa=ZRXbQEyw5-RvZrXTYMnRQr47=JuiUP3Ps4LGQPspo8gPQ@mail.gmail.com>
On Mon, Feb 23, 2026 at 04:11:52AM -0500, Karthik Nayak wrote:
Show 25 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> > diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
> > index 9032cc6327..02703f2fb8 100644
> > --- a/builtin/rev-parse.c
> > +++ b/builtin/rev-parse.c
> > @@ -613,13 +613,18 @@ static int opt_with_value(const char *arg, const char *opt, const char **value)
> >
> > static void handle_ref_opt(const char *pattern, const char *prefix)
> > {
> > - if (pattern)
> > + if (pattern) {
> > refs_for_each_glob_ref_in(get_main_ref_store(the_repository),
> > show_reference, pattern, prefix,
> > NULL);
> > - else
> > - refs_for_each_ref_in(get_main_ref_store(the_repository),
> > - prefix, show_reference, NULL);
> > + } else {
> > + struct refs_for_each_ref_options opts = {
> > + .prefix = prefix,
> > + .trim_prefix = strlen(prefix),
>
> Tangent: I wonder if it makes sense to make `trim_prefix` a bool and
> then internally trim strlen(prefix). Is there a usecase where
> `.trim_prefix != strlen(prefix)`?I don't think there is right now, and I cannot think about any myself. How about we leave this as a #leftoverbit though?
Patrick