From: Junio C Hamano Date: Thu, 22 May 2025 18:44:43 GMT Subject: Re: [PATCH v2 2/2] midx: stop repeatedly looking up nonexistent packfiles Message-ID: In-Reply-To: <20250522165924.GA1613@coredump.intra.peff.net> Jeff King writes: > But back in the caller... > >> p = m->packs[pack_int_id - m->num_packs_in_base]; >> ... > > Our pack_int_id is the global one, so it needs to be adjusted. But this > pack pointer we access is the same one that was filled (or not) by > prepare_midx_pack(). So it cannot be NULL or the magic "fails" value, > because prepare_midx_pack() returned 0. > > So I think this code is fine. Ahh, I missed that call to midx_for_pack() in prepare_midx_pack() that modifies pack_int_id variable. Of course, it did not help that the implementation detail of adjusting by m->num_packs_in_base which is done in midx_for_pack() is not abstracted out and the caller needs to do the same as above. That confused me. Thanks for an explanation.