Skip to content

Commit 26afb5a

Browse files
ttaylorrgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1820bd8 commit 26afb5a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

midx.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,11 @@ struct object_id *nth_midxed_object_oid(struct object_id *oid,
338338
struct multi_pack_index *m,
339339
uint32_t n)
340340
{
341-
if (n >= m->num_objects)
341+
if (n >= m->num_objects + m->num_objects_in_base)
342342
return NULL;
343343

344+
n = midx_for_object(&m, n);
345+
344346
oidread(oid, m->chunk_oid_lookup + st_mult(m->hash_len, n),
345347
the_repository->hash_algo);
346348
return oid;

0 commit comments

Comments
 (0)