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
22
midx-write.c
22
midx-write.c
@@ -916,26 +916,8 @@ cleanup:
|
||||
static struct multi_pack_index *lookup_multi_pack_index(struct repository *r,
|
||||
const char *object_dir)
|
||||
{
|
||||
struct multi_pack_index *result = NULL;
|
||||
struct multi_pack_index *cur;
|
||||
char *obj_dir_real = real_pathdup(object_dir, 1);
|
||||
struct strbuf cur_path_real = STRBUF_INIT;
|
||||
|
||||
/* Ensure the given object_dir is local, or a known alternate. */
|
||||
odb_find_source(r->objects, obj_dir_real);
|
||||
|
||||
for (cur = get_multi_pack_index(r); cur; cur = cur->next) {
|
||||
strbuf_realpath(&cur_path_real, cur->object_dir, 1);
|
||||
if (!strcmp(obj_dir_real, cur_path_real.buf)) {
|
||||
result = cur;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
free(obj_dir_real);
|
||||
strbuf_release(&cur_path_real);
|
||||
return result;
|
||||
struct odb_source *source = odb_find_source(r->objects, object_dir);
|
||||
return get_multi_pack_index(source);
|
||||
}
|
||||
|
||||
static int fill_packs_from_midx(struct write_midx_context *ctx,
|
||||
|
||||
Reference in New Issue
Block a user