From 4d8be89d973b69a826911385c5cf3d40d347394b Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 15 Jul 2025 13:29:18 +0200 Subject: [PATCH 1/7] midx: start tracking per object database source Multi-pack indices are tracked via `struct multi_pack_index`. This data structure is stored as a linked list inside `struct object_database`, which is the global database that spans across all of the object sources. This layout causes two problems: - Object databases consist of multiple object sources (e.g. one source per alternate object directory), where each multi-pack index is specific to one of those sources. Regardless of that though, the MIDX is not tracked per source, but tracked globally for the whole object database. This creates a mismatch between the on-disk layout and how things are organized in the object database subsystems and makes some parts, like figuring out whether a source has an MIDX, quite awkward. - Multi-pack indices are an implementation detail of how efficient access for packfiles work. As such, they are neither relevant in the context of loose objects, nor in a potential future where we have pluggable backends. Refactor `prepare_multi_pack_index_one()` so that it works on a specific source, which allows us to easily store a pointer to the multi-pack index inside of it. For now, this pointer exists next to the existing linked list we have in the object database. Users will be adjusted in subsequent patches to instead use the per-source pointers. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- midx.c | 19 +++++++++++-------- midx.h | 3 ++- odb.h | 9 ++++++++- packfile.c | 4 +++- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/midx.c b/midx.c index 3c5bc82173..2f64c26058 100644 --- a/midx.c +++ b/midx.c @@ -724,28 +724,29 @@ int midx_preferred_pack(struct multi_pack_index *m, uint32_t *pack_int_id) return 0; } -int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, int local) +int prepare_multi_pack_index_one(struct odb_source *source, int local) { + struct repository *r = source->odb->repo; struct multi_pack_index *m; - struct multi_pack_index *m_search; prepare_repo_settings(r); if (!r->settings.core_multi_pack_index) return 0; - for (m_search = r->objects->multi_pack_index; m_search; m_search = m_search->next) - if (!strcmp(object_dir, m_search->object_dir)) - return 1; - - m = load_multi_pack_index(r, object_dir, local); + if (source->midx) + return 1; + m = load_multi_pack_index(r, source->path, local); if (m) { struct multi_pack_index *mp = r->objects->multi_pack_index; if (mp) { m->next = mp->next; mp->next = m; - } else + } else { r->objects->multi_pack_index = m; + } + source->midx = m; + return 1; } @@ -837,6 +838,8 @@ void clear_midx_file(struct repository *r) if (r->objects && r->objects->multi_pack_index) { close_midx(r->objects->multi_pack_index); r->objects->multi_pack_index = NULL; + for (struct odb_source *source = r->objects->sources; source; source = source->next) + source->midx = NULL; } if (remove_path(midx.buf)) diff --git a/midx.h b/midx.h index 9d1374cbd5..639a6f50e4 100644 --- a/midx.h +++ b/midx.h @@ -8,6 +8,7 @@ struct pack_entry; struct repository; struct bitmapped_pack; struct git_hash_algo; +struct odb_source; #define MIDX_SIGNATURE 0x4d494458 /* "MIDX" */ #define MIDX_VERSION 1 @@ -123,7 +124,7 @@ int fill_midx_entry(struct repository *r, const struct object_id *oid, struct pa int midx_contains_pack(struct multi_pack_index *m, const char *idx_or_pack_name); int midx_preferred_pack(struct multi_pack_index *m, uint32_t *pack_int_id); -int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, int local); +int prepare_multi_pack_index_one(struct odb_source *source, int local); /* * Variant of write_midx_file which writes a MIDX containing only the packs diff --git a/odb.h b/odb.h index e922f25680..f09dba1fe1 100644 --- a/odb.h +++ b/odb.h @@ -13,6 +13,7 @@ struct oidmap; struct oidtree; struct strbuf; struct repository; +struct multi_pack_index; /* * Compute the exact path an alternate is at and returns it. In case of @@ -55,6 +56,13 @@ struct odb_source { /* Map between object IDs for loose objects. */ struct loose_object_map *loose_map; + /* + * private data + * + * should only be accessed directly by packfile.c and midx.c + */ + struct multi_pack_index *midx; + /* * This is a temporary object store created by the tmp_objdir * facility. Disable ref updates since the objects in the store @@ -75,7 +83,6 @@ struct odb_source { }; struct packed_git; -struct multi_pack_index; struct cached_object_entry; /* diff --git a/packfile.c b/packfile.c index af9ccfdba6..8bdd85fc7e 100644 --- a/packfile.c +++ b/packfile.c @@ -372,6 +372,8 @@ void close_object_store(struct object_database *o) if (o->multi_pack_index) { close_midx(o->multi_pack_index); o->multi_pack_index = NULL; + for (struct odb_source *source = o->sources; source; source = source->next) + source->midx = NULL; } close_commit_graph(o); @@ -1037,7 +1039,7 @@ static void prepare_packed_git(struct repository *r) odb_prepare_alternates(r->objects); for (source = r->objects->sources; source; source = source->next) { int local = (source == r->objects->sources); - prepare_multi_pack_index_one(r, source->path, local); + prepare_multi_pack_index_one(source, local); prepare_packed_git_one(r, source->path, local); } rearrange_packed_git(r); From ec4380f446b76e931002481f3e4be520c77058b6 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 15 Jul 2025 13:29:19 +0200 Subject: [PATCH 2/7] packfile: refactor `prepare_packed_git_one()` to work on sources In the preceding commit we refactored how we load multi-pack indices to take a corresponding "source" as input. As part of this refactoring we started to store a pointer to the MIDX in `struct odb_source` itself. Refactor loading of packfiles in the same way: instead of passing in the object directory, we now pass in the source from which we want to load packfiles. This allows us to simplify the code because we don't have to search for a corresponding MIDX anymore, but we can instead directly use the MIDX that we have already prepared beforehand. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- packfile.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/packfile.c b/packfile.c index 8bdd85fc7e..0b3142973b 100644 --- a/packfile.c +++ b/packfile.c @@ -935,22 +935,17 @@ static void prepare_pack(const char *full_name, size_t full_name_len, report_garbage(PACKDIR_FILE_GARBAGE, full_name); } -static void prepare_packed_git_one(struct repository *r, char *objdir, int local) +static void prepare_packed_git_one(struct odb_source *source, int local) { - struct prepare_pack_data data; struct string_list garbage = STRING_LIST_INIT_DUP; + struct prepare_pack_data data = { + .m = source->midx, + .r = source->odb->repo, + .garbage = &garbage, + .local = local, + }; - data.m = r->objects->multi_pack_index; - - /* look for the multi-pack-index for this object directory */ - while (data.m && strcmp(data.m->object_dir, objdir)) - data.m = data.m->next; - - data.r = r; - data.garbage = &garbage; - data.local = local; - - for_each_file_in_pack_dir(objdir, prepare_pack, &data); + for_each_file_in_pack_dir(source->path, prepare_pack, &data); report_pack_garbage(data.garbage); string_list_clear(data.garbage, 0); @@ -1040,7 +1035,7 @@ static void prepare_packed_git(struct repository *r) for (source = r->objects->sources; source; source = source->next) { int local = (source == r->objects->sources); prepare_multi_pack_index_one(source, local); - prepare_packed_git_one(r, source->path, local); + prepare_packed_git_one(source, local); } rearrange_packed_git(r); From 6567432ab4f93f63cd2111197c91651a9b04c517 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 15 Jul 2025 13:29:20 +0200 Subject: [PATCH 3/7] midx: stop using linked list when closing MIDX When calling `close_midx()` we not only close the multi-pack index for one object source, but instead we iterate through the whole linked list of MIDXs to close all of them. This linked list is about to go away in favor of using the new per-source pointer to its respective MIDX. Refactor the function to iterate through sources instead. Note that after this patch, there's a couple of callsites left that continue to use `close_midx()` without iterating through all sources. These are all cases where we don't care about the MIDX from other sources though, so it's fine to keep them as-is. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- midx.c | 13 ++++++++----- packfile.c | 11 ++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/midx.c b/midx.c index 2f64c26058..472d6bf17a 100644 --- a/midx.c +++ b/midx.c @@ -401,7 +401,6 @@ void close_midx(struct multi_pack_index *m) if (!m) return; - close_midx(m->next); close_midx(m->base_midx); munmap((unsigned char *)m->data, m->data_len); @@ -835,11 +834,15 @@ void clear_midx_file(struct repository *r) get_midx_filename(r->hash_algo, &midx, r->objects->sources->path); - if (r->objects && r->objects->multi_pack_index) { - close_midx(r->objects->multi_pack_index); - r->objects->multi_pack_index = NULL; - for (struct odb_source *source = r->objects->sources; source; source = source->next) + if (r->objects) { + struct odb_source *source; + + for (source = r->objects->sources; source; source = source->next) { + if (source->midx) + close_midx(source->midx); source->midx = NULL; + } + r->objects->multi_pack_index = NULL; } if (remove_path(midx.buf)) diff --git a/packfile.c b/packfile.c index 0b3142973b..7b350f018c 100644 --- a/packfile.c +++ b/packfile.c @@ -361,6 +361,7 @@ void close_pack(struct packed_git *p) void close_object_store(struct object_database *o) { + struct odb_source *source; struct packed_git *p; for (p = o->packed_git; p; p = p->next) @@ -369,12 +370,12 @@ void close_object_store(struct object_database *o) else close_pack(p); - if (o->multi_pack_index) { - close_midx(o->multi_pack_index); - o->multi_pack_index = NULL; - for (struct odb_source *source = o->sources; source; source = source->next) - source->midx = NULL; + for (source = o->sources; source; source = source->next) { + if (source->midx) + close_midx(source->midx); + source->midx = NULL; } + o->multi_pack_index = NULL; close_commit_graph(o); } From 736bb725ebcd37d567455db2ac50524dea11223c Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 15 Jul 2025 13:29:21 +0200 Subject: [PATCH 4/7] 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 Signed-off-by: Junio C Hamano --- builtin/pack-objects.c | 10 +++++++--- builtin/repack.c | 10 +++++----- midx-write.c | 22 ++-------------------- object-name.c | 22 +++++++++++++++------- pack-bitmap.c | 21 +++++++++++++++------ packfile.c | 31 ++++++++++++------------------- packfile.h | 3 +-- 7 files changed, 57 insertions(+), 62 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 067b9e322a..3dd84495b8 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1706,8 +1706,8 @@ static int want_object_in_pack_mtime(const struct object_id *oid, uint32_t found_mtime) { int want; + struct odb_source *source; struct list_head *pos; - struct multi_pack_index *m; if (!exclude && local && has_loose_object_nonlocal(oid)) return 0; @@ -1727,9 +1727,13 @@ static int want_object_in_pack_mtime(const struct object_id *oid, *found_offset = 0; } - for (m = get_multi_pack_index(the_repository); m; m = m->next) { + odb_prepare_alternates(the_repository->objects); + + for (source = the_repository->objects->sources; source; source = source->next) { + struct multi_pack_index *m = get_multi_pack_index(source); struct pack_entry e; - if (fill_midx_entry(the_repository, oid, &e, m)) { + + if (m && fill_midx_entry(the_repository, oid, &e, m)) { want = want_object_in_pack_one(e.p, oid, exclude, found_pack, found_offset, found_mtime); if (want != -1) return want; diff --git a/builtin/repack.c b/builtin/repack.c index 5e89d96df1..d63e1a9fec 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -223,9 +223,9 @@ static void mark_packs_for_deletion(struct existing_packs *existing, static void remove_redundant_pack(const char *dir_name, const char *base_name) { struct strbuf buf = STRBUF_INIT; - struct multi_pack_index *m = get_local_multi_pack_index(the_repository); + struct multi_pack_index *m = get_multi_pack_index(the_repository->objects->sources); strbuf_addf(&buf, "%s.pack", base_name); - if (m && midx_contains_pack(m, buf.buf)) + if (m && m->local && midx_contains_pack(m, buf.buf)) clear_midx_file(the_repository); strbuf_insertf(&buf, 0, "%s/", dir_name); unlink_pack_path(buf.buf, 1); @@ -1531,7 +1531,7 @@ int cmd_repack(int argc, * midx_has_unknown_packs() will make the decision for * us. */ - if (!get_local_multi_pack_index(the_repository)) + if (!get_multi_pack_index(the_repository->objects->sources)) midx_must_contain_cruft = 1; } @@ -1614,9 +1614,9 @@ int cmd_repack(int argc, string_list_sort(&names); - if (get_local_multi_pack_index(the_repository)) { + if (get_multi_pack_index(the_repository->objects->sources)) { struct multi_pack_index *m = - get_local_multi_pack_index(the_repository); + get_multi_pack_index(the_repository->objects->sources); ALLOC_ARRAY(midx_pack_names, m->num_packs + m->num_packs_in_base); 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, diff --git a/object-name.c b/object-name.c index ddafe7f9b1..27138b55b4 100644 --- a/object-name.c +++ b/object-name.c @@ -198,16 +198,20 @@ static void unique_in_pack(struct packed_git *p, static void find_short_packed_object(struct disambiguate_state *ds) { - struct multi_pack_index *m; + struct odb_source *source; struct packed_git *p; /* Skip, unless oids from the storage hash algorithm are wanted */ if (ds->bin_pfx.algo && (&hash_algos[ds->bin_pfx.algo] != ds->repo->hash_algo)) return; - for (m = get_multi_pack_index(ds->repo); m && !ds->ambiguous; - m = m->next) - unique_in_midx(m, ds); + odb_prepare_alternates(ds->repo->objects); + for (source = ds->repo->objects->sources; source && !ds->ambiguous; source = source->next) { + struct multi_pack_index *m = get_multi_pack_index(source); + if (m) + unique_in_midx(m, ds); + } + for (p = get_packed_git(ds->repo); p && !ds->ambiguous; p = p->next) unique_in_pack(p, ds); @@ -792,11 +796,15 @@ static void find_abbrev_len_for_pack(struct packed_git *p, static void find_abbrev_len_packed(struct min_abbrev_data *mad) { - struct multi_pack_index *m; struct packed_git *p; - for (m = get_multi_pack_index(mad->repo); m; m = m->next) - find_abbrev_len_for_midx(m, mad); + odb_prepare_alternates(mad->repo->objects); + for (struct odb_source *source = mad->repo->objects->sources; source; source = source->next) { + struct multi_pack_index *m = get_multi_pack_index(source); + if (m) + find_abbrev_len_for_midx(m, mad); + } + for (p = get_packed_git(mad->repo); p; p = p->next) find_abbrev_len_for_pack(p, mad); } 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); } diff --git a/packfile.c b/packfile.c index 7b350f018c..d0f38a0203 100644 --- a/packfile.c +++ b/packfile.c @@ -963,14 +963,18 @@ static void prepare_packed_git(struct repository *r); unsigned long repo_approximate_object_count(struct repository *r) { if (!r->objects->approximate_object_count_valid) { - unsigned long count; - struct multi_pack_index *m; + struct odb_source *source; + unsigned long count = 0; struct packed_git *p; prepare_packed_git(r); - count = 0; - for (m = get_multi_pack_index(r); m; m = m->next) - count += m->num_objects; + + for (source = r->objects->sources; source; source = source->next) { + struct multi_pack_index *m = get_multi_pack_index(source); + if (m) + count += m->num_objects; + } + for (p = r->objects->packed_git; p; p = p->next) { if (open_pack_index(p)) continue; @@ -1074,21 +1078,10 @@ struct packed_git *get_packed_git(struct repository *r) return r->objects->packed_git; } -struct multi_pack_index *get_multi_pack_index(struct repository *r) +struct multi_pack_index *get_multi_pack_index(struct odb_source *source) { - prepare_packed_git(r); - return r->objects->multi_pack_index; -} - -struct multi_pack_index *get_local_multi_pack_index(struct repository *r) -{ - struct multi_pack_index *m = get_multi_pack_index(r); - - /* no need to iterate; we always put the local one first (if any) */ - if (m && m->local) - return m; - - return NULL; + prepare_packed_git(source->odb->repo); + return source->midx; } struct packed_git *get_all_packs(struct repository *r) diff --git a/packfile.h b/packfile.h index 53c3b7d3b4..f16753f2a9 100644 --- a/packfile.h +++ b/packfile.h @@ -147,8 +147,7 @@ void install_packed_git(struct repository *r, struct packed_git *pack); struct packed_git *get_packed_git(struct repository *r); struct list_head *get_packed_git_mru(struct repository *r); -struct multi_pack_index *get_multi_pack_index(struct repository *r); -struct multi_pack_index *get_local_multi_pack_index(struct repository *r); +struct multi_pack_index *get_multi_pack_index(struct odb_source *source); struct packed_git *get_all_packs(struct repository *r); /* From 7fc19983926af6aea1eb393a5deb7bb2fc3cd495 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 15 Jul 2025 13:29:22 +0200 Subject: [PATCH 5/7] packfile: stop using linked MIDX list in `find_pack_entry()` Refactor `find_pack_entry()` so that we stop using the linked list of multi-pack indices. Note that there is no need to explicitly prepare alternates, and neither do we have to use `get_multi_pack_index()`, because `prepare_packed_git()` already takes care of populating all data structures for us. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- packfile.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packfile.c b/packfile.c index d0f38a0203..2d19c53ea9 100644 --- a/packfile.c +++ b/packfile.c @@ -2074,16 +2074,15 @@ static int fill_pack_entry(const struct object_id *oid, int find_pack_entry(struct repository *r, const struct object_id *oid, struct pack_entry *e) { struct list_head *pos; - struct multi_pack_index *m; prepare_packed_git(r); - if (!r->objects->packed_git && !r->objects->multi_pack_index) - return 0; - for (m = r->objects->multi_pack_index; m; m = m->next) { - if (fill_midx_entry(r, oid, e, m)) + for (struct odb_source *source = r->objects->sources; source; source = source->next) + if (source->midx && fill_midx_entry(r, oid, e, source->midx)) return 1; - } + + if (!r->objects->packed_git) + return 0; list_for_each(pos, &r->objects->packed_git_mru) { struct packed_git *p = list_entry(pos, struct packed_git, mru); From c620586fccf5a62e36a2d6cc96d0427f93f123fc Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 15 Jul 2025 13:29:23 +0200 Subject: [PATCH 6/7] packfile: stop using linked MIDX list in `get_all_packs()` Refactor `get_all_packs()` so that we stop using the linked list of multi-pack indices. Note that there is no need to explicitly prepare alternates, and neither do we have to use `get_multi_pack_index()`, because `prepare_packed_git()` already takes care of populating all data structures for us. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- packfile.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packfile.c b/packfile.c index 2d19c53ea9..ff33692f4b 100644 --- a/packfile.c +++ b/packfile.c @@ -1086,12 +1086,13 @@ struct multi_pack_index *get_multi_pack_index(struct odb_source *source) struct packed_git *get_all_packs(struct repository *r) { - struct multi_pack_index *m; - prepare_packed_git(r); - for (m = r->objects->multi_pack_index; m; m = m->next) { - uint32_t i; - for (i = 0; i < m->num_packs + m->num_packs_in_base; i++) + + for (struct odb_source *source = r->objects->sources; source; source = source->next) { + struct multi_pack_index *m = source->midx; + if (!m) + continue; + for (uint32_t i = 0; i < m->num_packs + m->num_packs_in_base; i++) prepare_midx_pack(r, m, i); } From ec865d94d4615c00fbf9ac50f4274b1d3fbf73a6 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 15 Jul 2025 13:29:24 +0200 Subject: [PATCH 7/7] midx: remove now-unused linked list of multi-pack indices In the preceding commits we have migrated all users of the linked list of multi-pack indices to instead use those stored in the object database sources. Remove those now-unused pointers. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- midx.c | 18 ++---------------- midx.h | 2 -- odb.h | 7 ------- packfile.c | 1 - 4 files changed, 2 insertions(+), 26 deletions(-) diff --git a/midx.c b/midx.c index 472d6bf17a..7d407682e6 100644 --- a/midx.c +++ b/midx.c @@ -726,7 +726,6 @@ int midx_preferred_pack(struct multi_pack_index *m, uint32_t *pack_int_id) int prepare_multi_pack_index_one(struct odb_source *source, int local) { struct repository *r = source->odb->repo; - struct multi_pack_index *m; prepare_repo_settings(r); if (!r->settings.core_multi_pack_index) @@ -735,21 +734,9 @@ int prepare_multi_pack_index_one(struct odb_source *source, int local) if (source->midx) return 1; - m = load_multi_pack_index(r, source->path, local); - if (m) { - struct multi_pack_index *mp = r->objects->multi_pack_index; - if (mp) { - m->next = mp->next; - mp->next = m; - } else { - r->objects->multi_pack_index = m; - } - source->midx = m; + source->midx = load_multi_pack_index(r, source->path, local); - return 1; - } - - return 0; + return !!source->midx; } int midx_checksum_valid(struct multi_pack_index *m) @@ -842,7 +829,6 @@ void clear_midx_file(struct repository *r) close_midx(source->midx); source->midx = NULL; } - r->objects->multi_pack_index = NULL; } if (remove_path(midx.buf)) diff --git a/midx.h b/midx.h index 639a6f50e4..076382de8a 100644 --- a/midx.h +++ b/midx.h @@ -35,8 +35,6 @@ struct odb_source; "GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL" struct multi_pack_index { - struct multi_pack_index *next; - const unsigned char *data; size_t data_len; diff --git a/odb.h b/odb.h index f09dba1fe1..09177bf430 100644 --- a/odb.h +++ b/odb.h @@ -123,13 +123,6 @@ struct object_database { struct commit_graph *commit_graph; unsigned commit_graph_attempted : 1; /* if loading has been attempted */ - /* - * private data - * - * should only be accessed directly by packfile.c and midx.c - */ - struct multi_pack_index *multi_pack_index; - /* * private data * diff --git a/packfile.c b/packfile.c index ff33692f4b..5d73932f50 100644 --- a/packfile.c +++ b/packfile.c @@ -375,7 +375,6 @@ void close_object_store(struct object_database *o) close_midx(source->midx); source->midx = NULL; } - o->multi_pack_index = NULL; close_commit_graph(o); }