From: Karthik Nayak Date: Mon, 23 Feb 2026 13:35:19 GMT Subject: Re: [PATCH 11/17] refs: replace `refs_for_each_ref_in()` Message-ID: In-Reply-To: Patrick Steinhardt writes: > On Mon, Feb 23, 2026 at 04:11:52AM -0500, Karthik Nayak wrote: >> Patrick Steinhardt 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 Sure!