Subject: Re: [PATCH v3 3/4] refs: selectively set prefix in the seek functions

From: Junio C Hamano <[email-masked]>
Date: Thu, 17 Jul 2025 10:31:44 -0700

Karthik Nayak <[email-masked]> writes:

>> Yes, even though I wouldn't call such an operation "seek", "Ah, I do
>> not need the entire refs/heads/ walked, only refs/heads/feature/ is
>> enough" is an operation mode that makes sense.
>>
>> But not for paging, though.

Actually, you are not using the new value for prefix; you are
unsetting prefix to nothing, so you do not stop when you go over the
boundary of refs/heads/feature/ hierarchy but will run through to
the end, so my worry is unfounded.

Which is good.

But the application has to decide when to stop as "We obtained an
iterator in order to list all branches in refs/heads/ and the last
round we gave refs/heads/main out.  Seek to it and continue the
output" will no longer stop after making a callback with
refs/heads/zz but will continue yielding non branch refs after that.

> The current implementation doesn't
> support '--start-after' and prefix setting at the same time:
>
> $ git for-each-ref --format="%(refname)"
> --start-after=refs/heads/master refs/heads
> fatal: cannot use --start-after with patterns

Good---in that case, "unsetting prefix to nothing" does not make any
difference and cannot introduce any confusing behaviour, as it has to
run to the end with or without "--start-after" anyway.

Thanks.