Re: [PATCH] ref-filter: restore prefix-scoped iteration
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 8, 2026, 21:36 UTC
- Message-ID
- <xmqqpl20vhni.fsf@gitster.g>
- In-Reply-To
- <20260605-fix-git-branch-regression-v1-1-02f40ad40929@gmail.com>
Tamir Duberstein <tamird@gmail.com> writes:
Show 8 quoted lines
> diff --git a/ref-filter.c b/ref-filter.c
> index 1da4c0e60d..2388a57b39 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -3315,19 +3315,31 @@ static int do_filter_refs(struct ref_filter *filter, unsigned int type, refs_for
> prefix = "refs/tags/";
>
> if (prefix) {Below, adding an extra call to get_main_ref_store(the_repository) makes one line unnecessarily split and harder to read. How about doing
struct ref_store *store = get_main_ref_store(the_repository);
upfront here, and then use that to replace these two calls of get_main_ref_store(the_repository)?
Show 26 quoted lines
> + if (filter->start_after) {
> + struct ref_iterator *iter;
>
> + iter = refs_ref_iterator_begin(
> + get_main_ref_store(the_repository), "", NULL, 0,
> + 0);
>
> ret = start_ref_iterator_after(iter, filter->start_after);
> + if (!ret)
> + ret = do_for_each_ref_iterator(iter, fn,
> + cb_data);
> + } else {
> + /*
> + * Pass the prefix during construction because the files
> + * backend primes loose refs before a later seek can
> + * narrow the iterator.
> + */
> + struct refs_for_each_ref_options opts = {
> + .prefix = prefix,
> + };
>
> + ret = refs_for_each_ref_ext(
> + get_main_ref_store(the_repository), fn, cb_data,
> + &opts);
> + }
> } else if (filter->kind & FILTER_REFS_REGULAR) {