diff options
| author | Patrick Steinhardt <ps@pks.im> | 2025-07-15 13:29:21 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-07-15 12:07:29 -0700 |
| commit | 736bb725ebcd37d567455db2ac50524dea11223c (patch) | |
| tree | 71e35b47700022912a7d0090bf578b28b9b7cf60 /midx-write.c | |
| parent | midx: stop using linked list when closing MIDX (diff) | |
| download | git-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 'midx-write.c')
| -rw-r--r-- | midx-write.c | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/midx-write.c b/midx-write.c index f2cfb85476..c1ae62d354 100644 --- a/midx-write.c +++ b/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, |
