Jeff King <peff@xxxxxxxx> writes: > The code in prepare_midx_pack() converts a numeric pack id (referenced > inside the midx) into a "struct packed_git" pointer, caching the results > in multi_pack_index->packs. That field holds NULL for "we have not > looked it up yet" or a valid pointer to a packed_git. It probably needs > to hold a third state: "we tried and failed". Yeah, this was exactly why I asked "are we having repeated failures in the same process", and I am happy with this direction. > Something like this (large untested) patch: > > diff --git a/midx.c b/midx.c > index 3d0015f782..354b1f886c 100644 > --- a/midx.c > +++ b/midx.c > @@ -405,7 +405,7 @@ void close_midx(struct multi_pack_index *m) > munmap((unsigned char *)m->data, m->data_len); > > for (i = 0; i < m->num_packs; i++) { > - if (m->packs[i]) > + if (m->packs[i] && m->packs[i] != (void *)(intptr_t)-1) > m->packs[i]->multi_pack_index = 0; > } > FREE_AND_NULL(m->packs); > @@ -458,6 +458,8 @@ int prepare_midx_pack(struct repository *r, struct multi_pack_index *m, > > pack_int_id = midx_for_pack(&m, pack_int_id); > > + if (m->packs[pack_int_id] == (void *)(intptr_t)-1) > + return 1; > if (m->packs[pack_int_id]) > return 0; > > @@ -482,8 +484,10 @@ int prepare_midx_pack(struct repository *r, struct multi_pack_index *m, > strbuf_release(&pack_name); > strbuf_release(&key); > > - if (!p) > + if (!p) { > + m->packs[pack_int_id] = (void *)(intptr_t)-1; > return 1; > + } > > p->multi_pack_index = 1; > m->packs[pack_int_id] = p;