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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jul 15, 2025 at 13:29 UTC 7fc19983926af6aea1eb393a5deb7bb2fc3cd495
1 file changed +5 -6
packfile.c
+5 -6
@@ -2074,16 +2074,15 @@ static int fill_pack_entry(const struct object_id *oid,
2074 int find_pack_entry(struct repository *r, const struct object_id *oid, struct pack_entry *e)
2075 {
2076 struct list_head *pos;
2077 - struct multi_pack_index *m;
2077
2078 prepare_packed_git(r);
2080 - if (!r->objects->packed_git && !r->objects->multi_pack_index)
2081 - return 0;
2079
2083 - for (m = r->objects->multi_pack_index; m; m = m->next) {
2084 - if (fill_midx_entry(r, oid, e, m))
2080 + for (struct odb_source *source = r->objects->sources; source; source = source->next)
2081 + if (source->midx && fill_midx_entry(r, oid, e, source->midx))
2082 return 1;
2086 - }
2083 +
2084 + if (!r->objects->packed_git)
2085 + return 0;
2086
2087 list_for_each(pos, &r->objects->packed_git_mru) {
2088 struct packed_git *p = list_entry(pos, struct packed_git, mru);