]> git.ipfire.org Git - thirdparty/git.git/commit
refs: generalize `refs_for_each_fullref_in_prefixes()`
authorPatrick Steinhardt <ps@pks.im>
Mon, 23 Feb 2026 11:59:43 +0000 (12:59 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Feb 2026 21:21:18 +0000 (13:21 -0800)
commitf503bb7dc96ee92623ade8d60eed401ecfddae0f
tree789daac4e90fe93e908969d2201982874770e972
parent5387919327574b5067f7efd986fca8793c95c71a
refs: generalize `refs_for_each_fullref_in_prefixes()`

The function `refs_for_each_fullref_in_prefixes()` can be used to
iterate over all references part of any of the user-provided prefixes.
In contrast to the `prefix` parameter of `refs_for_each_ref_ext()` it
knows to handle the case well where multiple of the passed-in prefixes
start with a common prefix by computing longest common prefixes and then
iterating over those.

While we could move this logic into `refs_for_each_ref_ext()`, this one
feels somewhat special as we perform multiple iterations. But what we
_can_ do is to generalize how this function works: instead of accepting
only a small handful of parameters, we can have it accept the full
options structure.

One obvious exception is that the caller must not provide a prefix via
the options. But this case can be easily detected.

Refactor the code accordingly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ls-refs.c
ref-filter.c
refs.c
refs.h