]> git.ipfire.org Git - thirdparty/git.git/commit
object-file: introduce function to iterate through objects
authorPatrick Steinhardt <ps@pks.im>
Mon, 26 Jan 2026 09:51:20 +0000 (10:51 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Jan 2026 16:26:07 +0000 (08:26 -0800)
commitcde615b6f05228cd7cf125de6bf5757381f65381
tree9a69f2000441dab1f7ee9c61325698e657b59c0c
parent6ecab3cdf67012592734ed9493db634d39326d43
object-file: introduce function to iterate through objects

We have multiple divergent interfaces to iterate through objects of a
specific backend:

  - `for_each_loose_object()` yields all loose objects.

  - `for_each_packed_object()` (somewhat obviously) yields all packed
    objects.

These functions have different function signatures, which makes it hard
to create a common abstraction layer that covers both of these.

Introduce a new function `odb_source_loose_for_each_object()` to plug
this gap. This function doesn't take any data specific to loose objects,
but instead it accepts a `struct object_info` that will be populated the
exact same as if `odb_source_loose_read_object()` was called.

The benefit of this new interface is that we can continue to pass
backend-specific data, as `struct object_info` contains a union for
these exact use cases. This will allow us to unify how we iterate
through objects across both loose and packed objects in a subsequent
commit.

The `for_each_loose_object()` function continues to exist for now, but
it will be removed at the end of this patch series.

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