]> git.99rst.org Git - git.git/commit
pack-bitmap: handle objects at bitmap position zero
authorDavid Lin <redacted>
Tue, 28 Jul 2026 13:52:48 +0000 (09:52 -0400)
committerJunio C Hamano <redacted>
Tue, 28 Jul 2026 22:14:42 +0000 (15:14 -0700)
commitb56b48301ea221ae3dd6dc01f887f0b72e10e729
treeba5cd9a65ce1d41398bc854e7a34f5315dc89238
parente9019fcafe0040228b8631c30f97ae1adb61bcdc
pack-bitmap: handle objects at bitmap position zero

`bitmap_position()` only returns a negative value when an object is not
present in the bitmap index.

In `find_objects()`, we have added a check (11d45a6e6a) to avoid
processing a root whose reachability is already represented by the base
bitmap, but accidentally uses `pos > 0`. Consequently, it never performs
the membership test for an object at position zero.

If that object has an individual reachability bitmap, we unnecessarily
OR that bitmap into the base again. Otherwise, we add the object to the
not-mapped list, only for the subsequent pass to recognize that it is
already present. The latter pass correctly treats all non-negative
positions as valid, so this does not change the resulting object set,
but an off-by-one edge case.

Treat position zero as valid by changing the condition to `pos >= 0`.

The existing pseudo-merge traversal test exercises this case. Its
position-zero commit is presented through multiple roots. Before this
change, each occurrence is counted as a bitmap hit; afterwards, only
the first occurrence is counted. Assert the resulting hit count to
cover the boundary condition.

Also cover the non-pseudo-merge case by passing `HEAD` twice. The first
occurrence initializes the base from its stored bitmap, and the second
must recognize that position zero is already present.

Helped-by: Taylor Blau <redacted>
Signed-off-by: David Lin <redacted>
Signed-off-by: Junio C Hamano <redacted>
pack-bitmap.c
t/t5333-pseudo-merge-bitmaps.sh
git clone https://git.99rst.org/PROJECT