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

Re: [PATCH 1/8] t/helper: add 'test-tool bitmap write' subcommand

From
Taylor Blau <me@ttaylorr.com>
Date
Apr 14, 2026, 21:29 UTC
Message-ID
<ad6xn6KmP3TsdpcH@nand.local>
In-Reply-To
<xmqqik9t9vby.fsf@gitster.g>
On Tue, Apr 14, 2026 at 12:48:49PM -0700, Junio C Hamano wrote:
> I haven't been paying attention at all to pseudo-merge stuff, so my
> comment may be too trivial and/or misses the point, but please bear
> with me.

It has been a while since I have thought about pseudo-merges since I returned to the topic with this series, so bear with me just the same ;-).

Show 8 quoted lines
> > +	git init bitmap-write-helper &&
> > +	test_when_finished "rm -fr bitmap-write-helper" &&
>
> A tangent but the above two lines may want to be swapped.  "rm -fr"
> does not fail when bitmap-write-helper directory does not yet exist,
> so "prepare to clear anytime it fails from now on and then create"
> would be a safer order than "create, and prepare to clear anytime it
> fails from now on".

I agree. I vaguely remember discussing this on the list with Ævar years ago, but clearly we should register our cleanup handler before we do the thing that needs to be cleaned up in case it fails part of the way through.

Show 13 quoted lines
> So we bulk-created 64 commits, repacked into one, and then
> [...]
> wrote the tip-commit in "commits".
> [...]
> And told the new tool to write a bitmap file, with only that HEAD
> commit and nothing else to get bitmap.
>
> > +		test-tool bitmap list-commits | sort >actual &&
> > +		sort commits >expect &&
> > +		test_cmp expect actual &&
>
> And compare the list of bitmapped commits with the singleton HEAD
> (it is puzzling to sort a single element list, though).
That's right.
Show 14 quoted lines
> > +		git rev-list --count --objects --use-bitmap-index HEAD >actual &&
> > +		git rev-list --count --objects HEAD >expect &&
> > +		test_cmp expect actual
> > +	)
> > +'
> > +
> >  test_done
>
> If we look at the implementation of bitmap_write() below, the object
> name for HEAD is fed to bitmap_write_push_commit() with pseudo bit
> off.  After reading the list (which has only one element), we call
> select_pseudo_merges().  What do we expect to happen in this call?
> Since no bitmap_write_push_commit() call is made with pseudo bit on,
> we will return immediately without doing anything?

In this particular instance, nothing should happen, and this test isn't directly testing the pseudo-merge selection at all here. We don't expect any pseudo-merges to be generated here, only for us to limit the selection of which commits get bitmaps.

> After that bitmap_write_build() is called, and as this is expected
> to add bitmaps to the commits fed to bitmap_write_push_commit(), we
> are expecting to see bitmap given to HEAD (and nothing else)?
Yes.
Show 5 quoted lines
> I said it is unclear what is being tested.  Putting it another way,
> what could go wrong to cause this test to fail?  We give commit A,
> B, and C to "bitmap write", and it somehow chooses other commits to
> also give bitmap, which will be reported by "bitmap list-commits"
> and we detect that as a failure?

That's right, and to the point of your original question, I think a better name is warranted here, perhaps: "test-tool bitmap write limits bitmap selection" or something.

To the question of what it's testing, it's testing only its basic functionality of altering the selection of which commits receive bitmaps. In that sense I view it as a smoke test of that basic functionality more than anything else.

How about:
--- 8< ---
diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh
index 9489e59fa55..ea94735fd66 100755
--- a/t/t5310-pack-bitmaps.sh
+++ b/t/t5310-pack-bitmaps.sh
@@ -649,8 +649,8 @@ test_expect_success 'truncated bitmap fails gracefully (lookup table)' '
 '

 test_expect_success 'test-tool bitmap write' '
-	git init bitmap-write-helper &&
 	test_when_finished "rm -fr bitmap-write-helper" &&
+	git init bitmap-write-helper &&
 	(
 		cd bitmap-write-helper &&

@@ -659,12 +659,12 @@ test_expect_success 'test-tool bitmap write' '

 		pack="$(ls .git/objects/pack/pack-*.pack)" &&

-		git rev-parse HEAD >commits &&
-		test-tool bitmap write "$(basename $pack)" <commits &&
+		git rev-parse HEAD >in &&
+		test-tool bitmap write "$(basename $pack)" <in &&

-		test-tool bitmap list-commits | sort >actual &&
-		sort commits >expect &&
-		test_cmp expect actual &&
+		test-tool bitmap list-commits >bitmaps.raw &&
+		sort bitmaps.raw >bitmaps &&
+		test_cmp in bitmaps &&

 		git rev-list --count --objects --use-bitmap-index HEAD >actual &&
 		git rev-list --count --objects HEAD >expect &&
--- >8 ---

Thanks,
Taylor
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 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.