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>
This commit is contained in:
committed by
Junio C Hamano
parent
6567432ab4
commit
736bb725eb
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user