Skip to content

pack-bitmap: fix various pseudo-merge bugs

Taylor Blau git 3 versions – Applied

Status from this message: Queued. Thanks.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest9 patches 3 repliesApplied
  2. v29 patches 4 repliesSuperseded
  3. v18 patches 10 repliesSuperseded

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/9t/helper: add 'test-tool bitmap write' subcommandt/helper/test-bitmap.c t/t5310-pack-bitmaps.sh+136 -10 replies
2/9t5333: demonstrate various pseudo-merge bugst/t5333-pseudo-merge-bitmaps.sh+198 -00 replies
3/9pack-bitmap-write: sort pseudo-merge commit lookup table in pack orderpack-bitmap-write.c t/t5333-pseudo-merge-bitmaps.sh+21 -20 replies
4/9pack-bitmap: fix inverted binary search in `pseudo_merge_at()`pseudo-merge.c t/t5333-pseudo-merge-bitmaps.sh+3 -30 replies
5/9pack-bitmap: fix pseudo-merge lookup for shared commitspack-bitmap-write.c pseudo-merge.c t/t5333-pseudo-merge-bitmaps.sh+4 -40 replies
6/9pack-bitmap: parse commits in `find_pseudo_merge_group_for_ref()`pseudo-merge.c t/t5333-pseudo-merge-bitmaps.sh+14 -100 replies
7/9pack-bitmap: reject pseudo-merge "sampleRate" of 0Documentation/config/bitmap-pseudo-merge.adoc pseudo-merge.c t/t5333-pseudo-merge-bitmaps.sh+5 -50 replies
8/9Documentation: fix broken `sampleRate` in gitpacking(7)Documentation/gitpacking.adoc+2 -20 replies
9/9pack-bitmap: prevent pattern leak on pseudo-merge re-assignmentpseudo-merge.c t/t5333-pseudo-merge-bitmaps.sh+33 -10 replies

Reviews trailers per patch

None of the 9 patches has a Reviewed-by or Acked-by.

PatchElijah Newren
1/9
2/9
3/9
4/9
5/9
6/9
7/9
8/9Noticed-by
9/9

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/9] pack-bitmap: fix various pseudo-merge bugs

[Note to the maintainer: this series has been rebased onto the current tip of master, which is 7760f83b597 (Merge branch 'jc/neuter-sideband-fixup', 2026-05-11) at the time of writing].

This is a (very) small reroll of my series to fix several bugs in the pseudo-merge bitmap implementation. The only changes since last time are:

- consistently ordering test_when_finished "rm -fr ..." above git init in tests, and

- avoiding a single Git invocation on the left-hand side of a pipe in the final patch

Otherwise, the series is entirely unchanged save for the above and the rebase.

As usual, a range-diff is included below for convenience. The original cover letter is as follows:

========================================================================

This series fixes several bugs in the pseudo-merge bitmap implementation that caused the pseudo-merge application path to be effectively broken during fill-in traversal.

Peff noticed that this code path was never triggered by the existing test suite, and investigating that observation uncovered a handful of bugs, some compounding.

The first two patches introduce test infrastructure: a 'bitmap write' test helper that gives tests precise control over which commits receive individual bitmaps, and a set of "test_expect_failure" tests demonstrating each bug.

The next four patches fix the bugs in the per-commit pseudo-merge lookup:

- The pseudo-merge commit lookup table was sorted by OID rather than by bit position, causing the reader's binary search to fail.

- The binary search in pseudo_merge_at() had its lo/hi updates swapped.

- The extended pseudo-merge lookup path had three compounding bugs: a wrong entry-size calculation in the writer, a misinterpretation of extended table entries in the reader, and a silently-swallowed error check.

The final two patches fix issues in pseudo-merge group selection:

- find_pseudo_merge_group_for_ref() did not parse commits before inspecting their dates, so all candidates had date == 0 and were unconditionally placed in the "stable" bucket.

- The config validation for bitmapPseudoMerge.*.sampleRate accepted 0, which leads to a division by zero once the date classification is fixed and the unstable code path is exercised.

There is also a small fix for a regex leak when the pattern key is overridden in config.

Thanks in advance for your review!

Taylor Blau (9):
t/helper: add 'test-tool bitmap write' subcommand
t5333: demonstrate various pseudo-merge bugs
pack-bitmap-write: sort pseudo-merge commit lookup table in pack order
pack-bitmap: fix inverted binary search in pseudo_merge_at()
pack-bitmap: fix pseudo-merge lookup for shared commits
pack-bitmap: parse commits in find_pseudo_merge_group_for_ref()
pack-bitmap: reject pseudo-merge "sampleRate" of 0
Documentation: fix broken sampleRate in gitpacking(7)
pack-bitmap: prevent pattern leak on pseudo-merge re-assignment

 Documentation/config/bitmap-pseudo-merge.adoc |   4 +-
 Documentation/gitpacking.adoc                 |   4 +-
 pack-bitmap-write.c                           |  23 +-
 pseudo-merge.c                                |  19 +-
 t/helper/test-bitmap.c                        | 113 ++++++++-
 t/t5310-pack-bitmaps.sh                       |  24 ++
 t/t5333-pseudo-merge-bitmaps.sh               | 229 ++++++++++++++++++
 7 files changed, 402 insertions(+), 14 deletions(-)

Range-diff against v2:

 1:  c0df35f8ebd =  1:  9c7a829cbeb t/helper: add 'test-tool bitmap write' subcommand
 2:  11de3343726 =  2:  d1ed4aadf75 t5333: demonstrate various pseudo-merge bugs
 3:  8d908ab415e =  3:  bf3a9a07e5f pack-bitmap-write: sort pseudo-merge commit lookup table in pack order
 4:  07f70a07c20 !  4:  a1d341c92eb pack-bitmap: fix inverted binary search in `pseudo_merge_at()`
    @@ t/t5333-pseudo-merge-bitmaps.sh: test_expect_success 'apply pseudo-merges during
     +test_expect_success 'apply pseudo-merges from multiple groups during fill-in' '
      	test_when_finished "rm -fr pseudo-merge-fill-in-multi" &&
      	git init pseudo-merge-fill-in-multi &&
    -+	git init pseudo-merge-fill-in-multi &&
      	(
    - 		cd pseudo-merge-fill-in-multi &&
    - 
 5:  3ed0b39843f =  5:  06e3410d323 pack-bitmap: fix pseudo-merge lookup for shared commits
 6:  95f847211f3 =  6:  78cf7e6d80d pack-bitmap: parse commits in `find_pseudo_merge_group_for_ref()`
 7:  f8a01cfb893 =  7:  4dbf6686718 pack-bitmap: reject pseudo-merge "sampleRate" of 0
 8:  c37156502c0 =  8:  46d0ee2f168 Documentation: fix broken `sampleRate` in gitpacking(7)
 9:  b905fd5d0ae !  9:  9b17dab2cf7 pack-bitmap: prevent pattern leak on pseudo-merge re-assignment
    @@ t/t5333-pseudo-merge-bitmaps.sh: test_expect_success 'sampleRate=0 does not caus
      '
      
     +test_expect_success 'duplicate pseudo-merge pattern does not leak' '
    -+	git init pseudo-merge-dup-pattern &&
     +	test_when_finished "rm -fr pseudo-merge-dup-pattern" &&
    -+
    ++	git init pseudo-merge-dup-pattern &&
     +	(
     +		cd pseudo-merge-dup-pattern &&
     +
    @@ t/t5333-pseudo-merge-bitmaps.sh: test_expect_success 'sampleRate=0 does not caus
     +		git config bitmapPseudoMerge.test.threshold now &&
     +		git config bitmapPseudoMerge.test.stableThreshold never &&
     +
    -+		git rev-parse HEAD~63 |
    -+		test-tool bitmap write "$(basename $pack)" &&
    ++		git rev-parse HEAD~63 >in &&
    ++		test-tool bitmap write "$(basename $pack)" <in &&
     +
     +		test_pseudo_merges >merges &&
     +		test_line_count = 1 merges

base-commit: 7760f83b59750c27df653c5c46d0f80e44cfe02c

Signature · 1 line
2.54.0.76.g9b17dab2cf7