]> git.ipfire.org Git - thirdparty/git.git/commit
refs/iterator: provide infrastructure to re-seek iterators
authorPatrick Steinhardt <ps@pks.im>
Wed, 12 Mar 2025 15:56:16 +0000 (16:56 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Mar 2025 18:31:19 +0000 (11:31 -0700)
commit82c39c6055b5340f0e50acbe01a97e51d3907fec
tree74948f55c8e575f754cbbd00842f158b44e3f605
parentcec2b6f55a805c010d2acc81abf4cbc41b712130
refs/iterator: provide infrastructure to re-seek iterators

Reftable iterators need to be scrapped after they have either been
exhausted or aren't useful to the caller anymore, and it is explicitly
not possible to reuse them for iterations. But enabling for reuse of
iterators may allow us to tune them by reusing internal state of an
iterator. The reftable iterators for example can already be reused
internally, but we're not able to expose this to any users outside of
the reftable backend.

Introduce a new `.seek` function in the ref iterator vtable that allows
callers to seek an iterator multiple times. It is expected to be
functionally the same as calling `refs_ref_iterator_begin()` with a
different (or the same) prefix.

Note that it is not possible to adjust parameters other than the seeked
prefix for now, so exclude patterns, trimmed prefixes and flags will
remain unchanged. We do not have a usecase for changing these parameters
right now, but if we ever find one we can adapt accordingly.

Implement the callback for trivial cases. The other iterators will be
implemented in subsequent commits.

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