midx: teach `nth_midxed_object_oid()` about incremental MIDXs

The function `nth_midxed_object_oid()` returns the object ID for a given object position in the MIDX lexicographic order. Teach this function to instead operate over the concatenated lexicographic order defined in an earlier step so that it is able to be used with incremental MIDXs. To do this, we need to both (a) adjust the bounds check for the given 'n', as well as record the MIDX-local position after chasing the `->base_midx` pointer to find the MIDX which contains that object. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Aug 6, 2024 at 11:37 UTC 26afb5afa16c9ea7825fdeae05e31d619849ad4b
1 file changed +3 -1
midx.c
+3 -1
@@ -338,9 +338,11 @@ struct object_id *nth_midxed_object_oid(struct object_id *oid,
338 struct multi_pack_index *m,
339 uint32_t n)
340 {
341 - if (n >= m->num_objects)
341 + if (n >= m->num_objects + m->num_objects_in_base)
342 return NULL;
343
344 + n = midx_for_object(&m, n);
345 +
346 oidread(oid, m->chunk_oid_lookup + st_mult(m->hash_len, n),
347 the_repository->hash_algo);
348 return oid;