]> Kevux Git Server - rit/commit
refs: introduce `refs_for_each_ref_ext`
authorPatrick Steinhardt <ps@pks.im>
Mon, 23 Feb 2026 11:59:40 +0000 (12:59 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Feb 2026 21:21:18 +0000 (13:21 -0800)
commitaefcc9b367016581743e57adf667ee4d56691bb1
tree94bf657d9bf6be65188ecde55f39e4f3aad18404
parent635f08b7394b9dda013a0b78f4db11348dc7717b
refs: introduce `refs_for_each_ref_ext`

In the refs subsystem we have a proliferation of functions that all
iterate through references. (Almost) all of these functions internally
call `do_for_each_ref()` and provide slightly different arguments so
that one can control different aspects of its behaviour. This approach
doesn't really scale: every time there is a slightly different use case
for iterating through refs we create another new function.

This combinatorial explosion doesn't make a lot of sense: it leads to
confusing interfaces and heightens the maintenance burden.

Refactor the code to become more composable by:

  - Exposing `do_for_each_ref()` as `refs_for_each_ref_ext()`.

  - Introducing an options structure that lets the caller control
    individual options.

This gives us a much better foundation to build on going forward.

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