]> git.ipfire.org Git - thirdparty/git.git/commit
odb/source-packed: improve lookup when enumerating objects
authorPatrick Steinhardt <ps@pks.im>
Wed, 15 Jul 2026 06:22:31 +0000 (08:22 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Jul 2026 14:19:15 +0000 (07:19 -0700)
commit27bed41ebb11ffdfcb79cf74fd4122ac41420f26
tree84c2d65640b40aa6025191d316add9856c5a179d
parent37e3640f2509e54ca0681247f120eb505e695250
odb/source-packed: improve lookup when enumerating objects

When iterating through objects of a packed source that have a specific
prefix we do so via two different methods:

  - When a multi-pack index is available we use that one to efficiently
    loop through all objects.

  - We then loop through all packfiles that aren't covered by a
    multi-pack index.

Regardless of which mechanism we use, we then iterate through all the
objects indexed by the respective data structure. Curiously though,
while we use the indices for enumerating the objects, we completely
ignore it for the actual object lookup. Instead, we call into the
generic `odb_source_read_object_info()` function, which will itself
consult the indices to figure out where the object in question even
lives.

This has two consequences:

  - It's inefficient, as we basically have to figure out the position of
    the object a second time.

  - It's subtly wrong, as it may now happen that a specific object will
    be looked up via a different pack in case it exists multiple times.
    This is unlikely to have any real-world consequences, but it's still
    the wrong thing to do.

Fix the issue by using `packed_object_info()` directly. While at it,
rename the `store` variable to `source`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
odb/source-packed.c