Re: [PATCH 2/9] pack-bitmap: handle name-hash lookups in incremental bitmaps
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Nov 12, 2025, 11:25 UTC
- Message-ID
- <aRRuvQmlDMBiZolK@pks.im>
- In-Reply-To
- <20251112080151.GB979063@coredump.intra.peff.net>
On Wed, Nov 12, 2025 at 03:01:51AM -0500, Jeff King wrote:
Show 13 quoted lines
> diff --git a/pack-bitmap.c b/pack-bitmap.c
> index 291e1a9cf4..710b86a451 100644
> --- a/pack-bitmap.c
> +++ b/pack-bitmap.c
> @@ -213,6 +213,26 @@ static uint32_t bitmap_num_objects(struct bitmap_index *index)
> return index->pack->num_objects;
> }
>
> +static uint32_t bitmap_name_hash(struct bitmap_index *index, uint32_t pos)
> +{
> + if (bitmap_is_midx(index)) {
> + while (index && pos < index->midx->num_objects_in_base)
> + index = index->base;So we first find the MIDX that is supposed to contain the position.
> + if (!index)
> + BUG("NULL base bitmap for object position: %"PRIu32, pos);
> +
> + pos -= index->midx->num_objects_in_base;We then subtract the number of objects from all of our predeceding layers from the position. This should result in the position relative to the current layer.
Show 8 quoted lines
> + if (pos >= index->midx->num_objects)
> + BUG("out-of-bounds midx bitmap object at %"PRIu32, pos);
> + }
> +
> + if (!index->hashes)
> + return 0;
> +
> + return get_be32(index->hashes + pos);And we then return the value at that given position. Makes sense to me.
Patrick