git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 6/8] pack-bitmap: parse commits in `find_pseudo_merge_group_for_ref()`

From
Taylor Blau <me@ttaylorr.com>
Date
Apr 13, 2026, 23:56 UTC
Message-ID
<6d74c0a177a8d910aa0394add38f5d57573eebd9.1776124589.git.me@ttaylorr.com>
In-Reply-To
<cover.1776124588.git.me@ttaylorr.com>

`find_pseudo_merge_group_for_ref()` uses the commit's date to classify it as either "stable" (older than the stable threshold) or "unstable" (otherwise).

However, to find the relevant commit from a given OID, the function `find_pseudo_merge_group_for_ref()` uses `lookup_commit()` which does not parse commits.

Because an unparsed commit has its "date" set to zero, every candidate is placed in the "stable" bucket regardless of its actual committer timestamp. This means the `bitmapPseudoMerge.*.threshold` and `stableThreshold` configuration options have no effect: the stable/unstable split is always determined by comparing against zero rather than the real commit date.

The net result is that pseudo-merge groups are partitioned by `stableSize` instead of the intended decay-based sizing, and the `sampleRate` knob (which only applies to the unstable path) is never exercised.

Fix this by calling `repo_parse_commit()` after `lookup_commit()`, bailing out of the callback if parsing fails.

The corresponding test configures two pseudo-merge groups that both match all tags. The "stable" group uses `threshold=1.month.ago`, and the "all" group uses `threshold=now`. The test use our custom "GIT_TEST_DATE_NOW" environment variable by setting it to the value of "$test_tick" to align Git's notion of "now" (and therefore "1.month.ago") with the `test_tick` timestamps, so the commits appear to be younger than one month: only the "all" group matches them, producing exactly one pseudo-merge.

Without the fix every commit has `date == 0`, which satisfies `date <= threshold` for both groups (since 0 is older than one month ago), and the "stable" group erroneously matches as well.

Now that commits are correctly classified as "unstable", the bug described in the test exercising the "sampleRate=0" test is reachable, and the test is marked as failing. It will be fixed in a following commit.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 pseudo-merge.c                  |  2 ++
 t/t5333-pseudo-merge-bitmaps.sh | 22 ++++++++++++----------
 2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/pseudo-merge.c b/pseudo-merge.c
index 34e1da00b4e..d79e5fb649a 100644
--- a/pseudo-merge.c
+++ b/pseudo-merge.c
@@ -236,6 +236,8 @@ static int find_pseudo_merge_group_for_ref(const struct reference *ref, void *_d
 	c = lookup_commit(the_repository, maybe_peeled);
 	if (!c)
 		return 0;
+	if (repo_parse_commit(the_repository, c))
+		return 0;
 	if (!packlist_find(writer->to_pack, maybe_peeled))
 		return 0;
 
diff --git a/t/t5333-pseudo-merge-bitmaps.sh b/t/t5333-pseudo-merge-bitmaps.sh
index 8844a3bced9..63d2f64361d 100755
--- a/t/t5333-pseudo-merge-bitmaps.sh
+++ b/t/t5333-pseudo-merge-bitmaps.sh
@@ -592,32 +592,34 @@ test_expect_success 'apply pseudo-merges with overlapping groups during fill-in'
 	)
 '
 
-test_expect_failure 'pseudo-merge commits are correctly classified by date' '
+test_expect_success 'pseudo-merge commits are correctly classified by date' '
 	git init pseudo-merge-date-classification &&
 	test_when_finished "rm -fr pseudo-merge-date-classification" &&
 	(
 		cd pseudo-merge-date-classification &&
 
 		test_commit_bulk 64 &&
+
 		tag_everything &&
 		git repack -ad &&
 
 		pack="$(ls .git/objects/pack/pack-*.pack)" &&
 
 		# Configure two pseudo-merge groups: one that only
-		# matches "stable" refs (older than one month), and one
-		# that matches all refs. With 64 freshly-created tags
-		# (all younger than one month) the stable group should
-		# have zero pseudo-merges and the catch-all group should
-		# have one.
+		# matches "stable" refs (older than one month), and
+		# one that matches all refs. With 64 tags whose
+		# commits are all younger than one month, the
+		# "stable" group should have zero pseudo-merges and
+		# the "all" group should have one.
 		#
 		# Use GIT_TEST_DATE_NOW to align "now" (and therefore
 		# "1.month.ago") with the test_tick timestamps so that
 		# the commits are within the last month.
 		#
-		# This exercises the date-based classification in
-		# find_pseudo_merge_group_for_ref(), which requires
-		# that commits are parsed before inspecting their date.
+		# Without parsing the commit, its date field would
+		# be zero, causing it to satisfy date <= threshold
+		# for the "stable" group as well, and both groups
+		# would produce pseudo-merges.
 		git config bitmapPseudoMerge.stable.pattern "refs/tags/" &&
 		git config bitmapPseudoMerge.stable.maxMerges 64 &&
 		git config bitmapPseudoMerge.stable.stableThreshold never &&
@@ -637,7 +639,7 @@ test_expect_failure 'pseudo-merge commits are correctly classified by date' '
 	)
 '
 
-test_expect_success 'sampleRate=0 does not cause division by zero' '
+test_expect_failure 'sampleRate=0 does not cause division by zero' '
 	git init pseudo-merge-sample-rate-zero &&
 	test_when_finished "rm -fr pseudo-merge-sample-rate-zero" &&
 	(
-- 
2.54.0.rc1.73.g8f4e0170952
Previous: Taylor BlauNext: Taylor Blau
Message 16 of 46 in “pack-bitmap: fix various pseudo-merge bugs”
  1. 0/8 pack-bitmap: fix various pseudo-merge bugsTaylor Blau, Apr 13, 2026
  2. 1/8 t/helper: add 'test-tool bitmap write' subcommandTaylor Blau, Apr 13, 2026
  3. Junio C HamanoApr 14, 2026
  4. Taylor BlauApr 14, 2026
  5. Junio C HamanoApr 14, 2026
  6. Taylor BlauApr 14, 2026
  7. Junio C HamanoApr 14, 2026
  8. Taylor BlauApr 14, 2026
  9. Elijah NewrenApr 19, 2026
  10. Taylor BlauApr 21, 2026
  11. 2/8 t5333: demonstrate various pseudo-merge bugsTaylor Blau, Apr 13, 2026
  12. Elijah NewrenApr 19, 2026
  13. 3/8 pack-bitmap-write: sort pseudo-merge commit lookup table in pack orderTaylor Blau, Apr 13, 2026
  14. 4/8 pack-bitmap: fix inverted binary search in `pseudo_merge_at()`Taylor Blau, Apr 13, 2026
  15. 5/8 pack-bitmap: fix pseudo-merge lookup for shared commitsTaylor Blau, Apr 13, 2026
  16. 6/8 pack-bitmap: parse commits in `find_pseudo_merge_group_for_ref()`Taylor Blau, Apr 13, 2026
  17. 7/8 pack-bitmap: reject pseudo-merge "sampleRate" of 0Taylor Blau, Apr 13, 2026
  18. Elijah NewrenApr 19, 2026
  19. 8/8 pack-bitmap: prevent pattern leak on pseudo-merge re-assignmentTaylor Blau, Apr 13, 2026
  20. 0/9 pack-bitmap: fix various pseudo-merge bugsTaylor Blau, Apr 21, 2026
  21. 1/9 t/helper: add 'test-tool bitmap write' subcommandTaylor Blau, Apr 21, 2026
  22. 2/9 t5333: demonstrate various pseudo-merge bugsTaylor Blau, Apr 21, 2026
  23. 3/9 pack-bitmap-write: sort pseudo-merge commit lookup table in pack orderTaylor Blau, Apr 21, 2026
  24. 4/9 pack-bitmap: fix inverted binary search in `pseudo_merge_at()`Taylor Blau, Apr 21, 2026
  25. 5/9 pack-bitmap: fix pseudo-merge lookup for shared commitsTaylor Blau, Apr 21, 2026
  26. 6/9 pack-bitmap: parse commits in `find_pseudo_merge_group_for_ref()`Taylor Blau, Apr 21, 2026
  27. 7/9 pack-bitmap: reject pseudo-merge "sampleRate" of 0Taylor Blau, Apr 21, 2026
  28. 8/9 Documentation: fix broken `sampleRate` in gitpacking(7)Taylor Blau, Apr 21, 2026
  29. 9/9 pack-bitmap: prevent pattern leak on pseudo-merge re-assignmentTaylor Blau, Apr 21, 2026
  30. Elijah NewrenApr 22, 2026
  31. Junio C HamanoMay 11, 2026
  32. Taylor BlauMay 12, 2026
  33. Taylor BlauMay 12, 2026
  34. 0/9 pack-bitmap: fix various pseudo-merge bugsTaylor Blau, May 12, 2026
  35. 1/9 t/helper: add 'test-tool bitmap write' subcommandTaylor Blau, May 12, 2026
  36. 2/9 t5333: demonstrate various pseudo-merge bugsTaylor Blau, May 12, 2026
  37. 3/9 pack-bitmap-write: sort pseudo-merge commit lookup table in pack orderTaylor Blau, May 12, 2026
  38. 4/9 pack-bitmap: fix inverted binary search in `pseudo_merge_at()`Taylor Blau, May 12, 2026
  39. 5/9 pack-bitmap: fix pseudo-merge lookup for shared commitsTaylor Blau, May 12, 2026
  40. 6/9 pack-bitmap: parse commits in `find_pseudo_merge_group_for_ref()`Taylor Blau, May 12, 2026
  41. 7/9 pack-bitmap: reject pseudo-merge "sampleRate" of 0Taylor Blau, May 12, 2026
  42. 8/9 Documentation: fix broken `sampleRate` in gitpacking(7)Taylor Blau, May 12, 2026
  43. 9/9 pack-bitmap: prevent pattern leak on pseudo-merge re-assignmentTaylor Blau, May 12, 2026
  44. Junio C HamanoMay 12, 2026
  45. Taylor BlauMay 12, 2026
  46. Junio C HamanoMay 12, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.