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

Re: [PATCH 8/8] pseudo-merge.c: ensure pseudo-merge groups are closed

From
Jeff King <peff@peff.net>
Date
Aug 17, 2024, 10:43 UTC
Message-ID
<20240817104341.GD551779@coredump.intra.peff.net>
In-Reply-To
<c9a64b1d2a9d6b3fe1f5fb0a7303e043114fcd8f.1723743050.git.me@ttaylorr.com>
On Thu, Aug 15, 2024 at 01:31:20PM -0400, Taylor Blau wrote:
Show 7 quoted lines
> Rectify this by ensuring that the commits which are pseudo-merge
> candidates can only be so if they appear somewhere in the packing order.
> 
> This is sufficient, since we know that the original packing order is
> closed under reachability, so if a commit appears in that list as a
> potential pseudo-merge candidate, we know that everything reachable from
> it also appears in the list (and thus the candidate is a good one).
Right, good explanation.
Show 13 quoted lines
> diff --git a/pseudo-merge.c b/pseudo-merge.c
> index 6422be979c..7ec9d4c51c 100644
> --- a/pseudo-merge.c
> +++ b/pseudo-merge.c
> @@ -217,6 +217,8 @@ static int find_pseudo_merge_group_for_ref(const char *refname,
>  	c = lookup_commit(the_repository, oid);
>  	if (!c)
>  		return 0;
> +	if (!packlist_find(writer->to_pack, oid))
> +		return 0;
>  
>  	has_bitmap = bitmap_writer_has_bitmapped_object_id(writer, oid);
>  

And the patch looks good. I wondered about checking the packlist before calling lookup_commit(), but the latter is really not very expensive (it is not reading the object, but just creating a struct).

Show 23 quoted lines
> +test_expect_success 'pseudo-merge closure' '
> +	git init pseudo-merge-closure &&
> +	(
> +		cd pseudo-merge-closure &&
> +
> +		test_commit A &&
> +		git repack -d &&
> +
> +		test_commit B &&
> +
> +		# Note that the contents of A is packed, but B is not. A
> +		# (and the objects reachable from it) are thus visible
> +		# to the MIDX, but the same is not true for B and its
> +		# objects.
> +		#
> +		# Ensure that we do not attempt to create a pseudo-merge
> +		# for B, depsite it matching the below pseudo-merge
> +		# group pattern, as doing so would result in a failure
> +		# to write a non-closed bitmap.
> +		git config bitmapPseudoMerge.test.pattern refs/ &&
> +		git config bitmapPseudoMerge.test.threshold now &&
> +
> +		git multi-pack-index write --bitmap &&

OK, clever. In the real world, I think this would happen racily, because you'd usually suck up all of the loose objects into a pack to feed into the midx. And the problem is new objects (whether packed or not) that are referenced after that step.

But here we just skip that step and generate the midx directly, which lets us do it deterministically.

-Peff
Previous: Taylor BlauNext: Jeff King
Message 18 of 20 in “pseudo-merge: avoid empty and non-closed pseudo-merge commits”
  1. 0/8 pseudo-merge: avoid empty and non-closed pseudo-merge commitsTaylor Blau, Aug 15, 2024
  2. 1/8 pack-bitmap: initialize `bitmap_writer_init()` with packing_dataTaylor Blau, Aug 15, 2024
  3. Jeff KingAug 17, 2024
  4. Taylor BlauAug 29, 2024
  5. Jeff KingAug 29, 2024
  6. 2/8 pack-bitmap: drop redundant args from `bitmap_writer_build_type_index()`Taylor Blau, Aug 15, 2024
  7. 3/8 pack-bitmap: drop redundant args from `bitmap_writer_build()`Taylor Blau, Aug 15, 2024
  8. 4/8 pack-bitmap: drop redundant args from `bitmap_writer_finish()`Taylor Blau, Aug 15, 2024
  9. 5/8 pack-bitmap-write.c: select pseudo-merges even for small bitmapsTaylor Blau, Aug 15, 2024
  10. Jeff KingAug 17, 2024
  11. Junio C HamanoAug 17, 2024
  12. Taylor BlauAug 29, 2024
  13. 6/8 t/t5333-pseudo-merge-bitmaps.sh: demonstrate empty pseudo-merge groupsTaylor Blau, Aug 15, 2024
  14. 7/8 pseudo-merge.c: do not generate empty pseudo-merge commitsTaylor Blau, Aug 15, 2024
  15. Jeff KingAug 17, 2024
  16. Taylor BlauAug 29, 2024
  17. 8/8 pseudo-merge.c: ensure pseudo-merge groups are closedTaylor Blau, Aug 15, 2024
  18. Jeff KingAug 17, 2024
  19. Jeff KingAug 17, 2024
  20. Taylor BlauAug 29, 2024

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.