]> git.99rst.org Git - git.git/commit
odb: introduce object filters to `odb_for_each_object()`
authorPatrick Steinhardt <redacted>
Wed, 15 Jul 2026 06:22:38 +0000 (08:22 +0200)
committerJunio C Hamano <redacted>
Wed, 15 Jul 2026 14:19:16 +0000 (07:19 -0700)
commit204daf5e5c6f931352ddde16236e9705075d15bf
tree37c3b553cc1016ce45705aa07847c3e9345b76b1
parent8cd7ee7b0d12fce9449ea08fe394e18dc97fe059
odb: introduce object filters to `odb_for_each_object()`

The function `for_each_bitmapped_object()` can be used to iterate
through all objects covered by a bitmap. The benefit of this function is
that it allows the caller to efficiently handle some object filters. For
example, this can be used to filter out objects of a specific type with
some simple bitmap operations. But callers are currently required to
manually wire up the use of bitmaps though, and to do so they have to
reach into internals of a given object database source.

Introduce a new `struct odb_for_each_object_options::filter` field so
that the interface becomes generic. When set, then a backend may
optionally use the filter to skip some objects that it would have
otherwise yielded.

Note that the respective backends are free to ignore this field if they
cannot meaningfully optimize for a given filter, and consequently
callers need to verify whether they actually want the returned objects.
While annoying, we cannot easily lift this restriction anyway as the
object filter infrastructure supports some filters that cannot be
answered by the object database alone.

An alternative might be to limit the filters to only those that _can_ be
answered by backends. But ultimately, the filters that can be answered
efficiently by the "packed" backend are completely disjunct from those
that can be answered by the "loose" backend, and consequently the set of
filters supported by all backends would be empty. Furthermore, it would
require us to make assumptions about capabilities of future backends,
which may be able to efficiently handle more filters than current ones.
So in the end, this alternative would only limit us artificially.

Implement the logic for the "packed" source. Note that we use the new
function `prepare_bitmap_git_for_source()` to open the bitmap: as the
backend operates on a single object source, we must only use bitmaps
that belong to that specific source. Otherwise we might yield objects
that are not part of the source at all, and with multiple sources we
would enumerate the same bitmap once per source.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
odb.h
odb/source-packed.c
pack-bitmap.c
pack-bitmap.h
git clone https://git.99rst.org/PROJECT