Subject: Re: [PATCH 4/4] builtin/remote: only iterate through refs that are to be renamed

From: Junio C Hamano <[email-masked]>
Date: Mon, 28 Jul 2025 10:43:43 -0700

Patrick Steinhardt <[email-masked]> writes:

> When renaming a remote we also need to rename all references
> accordingly. But while we only need to rename references that are
> contained in the "refs/remotes/$OLDNAME/" namespace, we end up using
> `refs_for_each_rawref()` that iterates through _all_ references. We know
> to exit early in the callback in case we see an irrelevant reference,
> but ultimately this is still a waste of compute as we knowingly iterate
> through references that we won't ever care about.

Very true.  Even if we guarantee that callbacks are fed references in
lexicographic order, that would only allow us to stop iterationg
when we see an irrelevant one", and still would force us to skip
over all the irrelevant ones until we see the first one in scope.

It makes perfect sense to give us a way to say "iterate only in this
subhierarchy" like this step does.

Nice.