Skip to content

Commit 88f309e

Browse files
ttaylorrgitster
authored andcommitted
midx: teach bsearch_midx() about incremental MIDXs
Now that the special cases callers of `bsearch_midx()` have been dealt with, teach `bsearch_midx()` to handle incremental MIDX chains. The incremental MIDX-aware version of `bsearch_midx()` works by repeatedly searching for a given OID in each layer along the `->base_midx` pointer, stopping either when an exact match is found, or the end of the chain is reached. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3f5f1cf commit 88f309e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

midx.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,10 @@ int bsearch_one_midx(const struct object_id *oid, struct multi_pack_index *m,
344344
int bsearch_midx(const struct object_id *oid, struct multi_pack_index *m,
345345
uint32_t *result)
346346
{
347-
return bsearch_one_midx(oid, m, result);
347+
for (; m; m = m->base_midx)
348+
if (bsearch_one_midx(oid, m, result))
349+
return 1;
350+
return 0;
348351
}
349352

350353
struct object_id *nth_midxed_object_oid(struct object_id *oid,

0 commit comments

Comments
 (0)