]> git.ipfire.org Git - thirdparty/git.git/commitdiff
packfile: stop using linked MIDX list in `find_pack_entry()`
authorPatrick Steinhardt <ps@pks.im>
Tue, 15 Jul 2025 11:29:22 +0000 (13:29 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 15 Jul 2025 19:07:29 +0000 (12:07 -0700)
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 <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
packfile.c

index d0f38a020354abbf210252cfa93cd6305afd031e..2d19c53ea96a7ec92937a3f98552ad47cf86c466 100644 (file)
@@ -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);