]> git.ipfire.org Git - thirdparty/git.git/commit - pack-revindex.h
pack-revindex: implement `midx_pair_to_pack_pos()`
authorTaylor Blau <me@ttaylorr.com>
Thu, 14 Dec 2023 22:24:30 +0000 (17:24 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Dec 2023 22:38:08 +0000 (14:38 -0800)
commitdbd5c520d2bb168f58bde4ead407d35589142668
treecb2b9d2e7ff2eb966f797c15dff1498d5e95f1ad
parente1bfe30c4dd29a1a30569d04432d73675e497e86
pack-revindex: implement `midx_pair_to_pack_pos()`

Now that we have extracted the `midx_key_to_pack_pos()` function, we can
implement the `midx_pair_to_pack_pos()` function which accepts (pack_id,
offset) tuples and returns an index into the psuedo-pack order.

This will be used in a following commit in order to figure out whether
or not the MIDX chose a given delta's base object from the same pack as
the delta resides in. It will do so by locating the base object's offset
in the pack, and then performing a binary search using the same pack ID
with the base object's offset.

If (and only if) it finds a match (at any position) we can guarantee
that the MIDX selected both halves of the delta/base pair from the same
pack.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pack-revindex.c
pack-revindex.h