Merge branch 'dl/pack-bitmap-position-zero'

A boundary case check in reachability bitmap traversal has been
corrected to properly handle the object at position zero, which was
previously skipped, leading to redundant bitmap loading.

* dl/pack-bitmap-position-zero:
  pack-bitmap: handle objects at bitmap position zero
This commit is contained in:
Junio C Hamano
2026-08-07 14:48:01 -07:00
2 changed files with 14 additions and 2 deletions

View File

@@ -1569,7 +1569,7 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
if (base) {
int pos = bitmap_position(bitmap_git, &object->oid);
if (pos > 0 && bitmap_get(base, pos)) {
if (pos >= 0 && bitmap_get(base, pos)) {
object->flags |= SEEN;
continue;
}

View File

@@ -50,7 +50,15 @@ test_expect_success 'bitmap traversal without pseudo-merges' '
test_pseudo_merges_cascades 0 <trace2.txt &&
test_pseudo_merges >merges &&
test_must_be_empty merges &&
test_cmp expect actual
test_cmp expect actual &&
: >trace2.txt &&
GIT_TRACE2_EVENT=$PWD/trace2.txt \
git rev-list --objects --use-bitmap-index HEAD HEAD >/dev/null &&
# The first HEAD initializes base from its position-zero bitmap. The
# duplicate root should not count as another bitmap hit.
test_trace2_data bitmap bitmap/hits 1 <trace2.txt
'
test_expect_success 'pseudo-merges accurately represent their objects' '
@@ -85,6 +93,10 @@ test_expect_success 'bitmap traversal with pseudo-merges' '
test_pseudo_merges_satisfied 8 <trace2.txt &&
test_pseudo_merges_cascades 1 <trace2.txt &&
# Position zero is named by HEAD, its branch, and its tag, but it
# should count as only one bitmap hit.
test_trace2_data bitmap bitmap/hits 1 <trace2.txt &&
test_cmp expect actual
'