summaryrefslogtreecommitdiffstats
path: root/midx.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2024-08-06 17:37:33 +0200
committerJunio C Hamano <gitster@pobox.com>2024-08-06 21:01:37 +0200
commit88f309e095d084d730f908fe1ec01a92c63612c2 (patch)
treeb6be73267d8cd8f31badda6c8df4b7de8a4c3328 /midx.c
parentmidx: introduce `bsearch_one_midx()` (diff)
downloadgit-88f309e095d084d730f908fe1ec01a92c63612c2.tar.xz
git-88f309e095d084d730f908fe1ec01a92c63612c2.zip
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 <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'midx.c')
-rw-r--r--midx.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/midx.c b/midx.c
index bd6e3f26c9..83857cbd1e 100644
--- a/midx.c
+++ b/midx.c
@@ -344,7 +344,10 @@ int bsearch_one_midx(const struct object_id *oid, struct multi_pack_index *m,
int bsearch_midx(const struct object_id *oid, struct multi_pack_index *m,
uint32_t *result)
{
- return bsearch_one_midx(oid, m, result);
+ for (; m; m = m->base_midx)
+ if (bsearch_one_midx(oid, m, result))
+ return 1;
+ return 0;
}
struct object_id *nth_midxed_object_oid(struct object_id *oid,