midx: stop duplicating info redundant with its owning source

Multi-pack indices store some information that is redundant with their
owning source:

  - The locality bit that tracks whether the source is the primary
    object source or an alternate.

  - The object directory path the multi-pack index is located in.

  - The pointer to the owning parent directory.

All of this information is already contained in `struct odb_source`. So
now that we always have that struct available when loading a multi-pack
index we have it readily accessible.

Drop the redundant information and instead store a pointer to the object
source.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-08-11 15:46:49 +02:00
committed by Junio C Hamano
parent c3f5d25146
commit 7744936f37
7 changed files with 36 additions and 35 deletions

View File

@@ -216,7 +216,7 @@ static uint32_t bitmap_num_objects(struct bitmap_index *index)
static struct repository *bitmap_repo(struct bitmap_index *bitmap_git)
{
if (bitmap_is_midx(bitmap_git))
return bitmap_git->midx->repo;
return bitmap_git->midx->source->odb->repo;
return bitmap_git->pack->repo;
}
@@ -418,13 +418,13 @@ char *midx_bitmap_filename(struct multi_pack_index *midx)
{
struct strbuf buf = STRBUF_INIT;
if (midx->has_chain)
get_split_midx_filename_ext(midx->repo->hash_algo, &buf,
midx->object_dir,
get_split_midx_filename_ext(midx->source->odb->repo->hash_algo, &buf,
midx->source->path,
get_midx_checksum(midx),
MIDX_EXT_BITMAP);
else
get_midx_filename_ext(midx->repo->hash_algo, &buf,
midx->object_dir, get_midx_checksum(midx),
get_midx_filename_ext(midx->source->odb->repo->hash_algo, &buf,
midx->source->path, get_midx_checksum(midx),
MIDX_EXT_BITMAP);
return strbuf_detach(&buf, NULL);
@@ -463,7 +463,8 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
if (bitmap_git->pack || bitmap_git->midx) {
struct strbuf buf = STRBUF_INIT;
get_midx_filename(midx->repo->hash_algo, &buf, midx->object_dir);
get_midx_filename(midx->source->odb->repo->hash_algo, &buf,
midx->source->path);
trace2_data_string("bitmap", bitmap_repo(bitmap_git),
"ignoring extra midx bitmap file", buf.buf);
close(fd);