aboutsummaryrefslogtreecommitdiffstats
path: root/pack-bitmap.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-07-15 13:29:21 +0200
committerJunio C Hamano <gitster@pobox.com>2025-07-15 12:07:29 -0700
commit736bb725ebcd37d567455db2ac50524dea11223c (patch)
tree71e35b47700022912a7d0090bf578b28b9b7cf60 /pack-bitmap.c
parentmidx: stop using linked list when closing MIDX (diff)
downloadgit-736bb725ebcd37d567455db2ac50524dea11223c.tar.gz
git-736bb725ebcd37d567455db2ac50524dea11223c.zip
packfile: refactor `get_multi_pack_index()` to work on sources
The function `get_multi_pack_index()` loads multi-pack indices via `prepare_packed_git()` and then returns the linked list of multi-pack indices that is stored in `struct object_database`. That list is in the process of being removed though in favor of storing the MIDX as part of the object database source it belongs to. Refactor `get_multi_pack_index()` so that it returns the multi-pack index for a single object source. Callers are now expected to call this function for each source they are interested in. This requires them to iterate through alternates, so we have to prepare alternate object sources before doing so. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack-bitmap.c')
-rw-r--r--pack-bitmap.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 0a4af199c0..64278e2acf 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -691,13 +691,15 @@ static int open_pack_bitmap(struct repository *r,
static int open_midx_bitmap(struct repository *r,
struct bitmap_index *bitmap_git)
{
+ struct odb_source *source;
int ret = -1;
- struct multi_pack_index *midx;
assert(!bitmap_git->map);
- for (midx = get_multi_pack_index(r); midx; midx = midx->next) {
- if (!open_midx_bitmap_1(bitmap_git, midx))
+ odb_prepare_alternates(r->objects);
+ for (source = r->objects->sources; source; source = source->next) {
+ struct multi_pack_index *midx = get_multi_pack_index(source);
+ if (midx && !open_midx_bitmap_1(bitmap_git, midx))
ret = 0;
}
return ret;
@@ -3305,11 +3307,18 @@ static int verify_bitmap_file(const struct git_hash_algo *algop,
int verify_bitmap_files(struct repository *r)
{
+ struct odb_source *source;
int res = 0;
- for (struct multi_pack_index *m = get_multi_pack_index(r);
- m; m = m->next) {
- char *midx_bitmap_name = midx_bitmap_filename(m);
+ odb_prepare_alternates(r->objects);
+ for (source = r->objects->sources; source; source = source->next) {
+ struct multi_pack_index *m = get_multi_pack_index(source);
+ char *midx_bitmap_name;
+
+ if (!m)
+ continue;
+
+ midx_bitmap_name = midx_bitmap_filename(m);
res |= verify_bitmap_file(r->hash_algo, midx_bitmap_name);
free(midx_bitmap_name);
}