]> git.ipfire.org Git - thirdparty/git.git/commit
midx: load multi-pack indices via their source
authorPatrick Steinhardt <ps@pks.im>
Mon, 11 Aug 2025 13:46:47 +0000 (15:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 11 Aug 2025 16:22:22 +0000 (09:22 -0700)
commit017db7bb14246dea55b678fc20e34ce91c28968a
tree7805df854b8f84f3ef717c7b2be9ce1ba3c4a687
parent9ff212961506679c1e2c1541b17ab2bd8563ff15
midx: load multi-pack indices via their source

To load a multi-pack index the caller is expected to pass both the
repository and the object directory where the multi-pack index is
located. While this works, this layout has a couple of downsides:

  - We need to pass in information reduntant with the owning source,
    namely its object directory and whether the source is local or not.

  - We don't have access to the source when loading the multi-pack
    index. If we had that access, we could store a pointer to the owning
    source in the MIDX and thus deduplicate some information.

  - Multi-pack indices are inherently specific to the object source and
    its format. With the goal of pluggable object backends in mind we
    will eventually want the backends to own the logic of reading and
    writing multi-pack indices. Making the logic work on top of object
    sources is a step into that direction.

Refactor loading of multi-pack indices accordingly.

This surfaces one small problem though: git-multi-pack-index(1) and our
MIDX test helper both know to read and write multi-pack-indices located
in a different object directory. This issue is addressed by adding the
user-provided object directory as an in-memory alternate.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/multi-pack-index.c
midx.c
midx.h
t/helper/test-read-midx.c
t/t5319-multi-pack-index.sh