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

Re: [PATCH v5 9/9] repack: exclude cruft pack(s) from the MIDX where possible

From
Taylor Blau <me@ttaylorr.com>
Date
Jun 24, 2025, 16:05 UTC
Message-ID
<aFrM1ngJfL0Ssc9F@nand.local>
In-Reply-To
<20250624105447.GA716990@coredump.intra.peff.net>
On Tue, Jun 24, 2025 at 06:54:47AM -0400, Jeff King wrote:
Show 45 quoted lines
> > If we do this on top:
> >
> > --- 8< ---
> > diff --git a/builtin/repack.c b/builtin/repack.c
> > index 346d44fbcd..8d1540a0fd 100644
> > --- a/builtin/repack.c
> > +++ b/builtin/repack.c
> > @@ -1614,13 +1614,16 @@ int cmd_repack(int argc,
> >  	string_list_sort(&names);
> >
> >  	if (get_local_multi_pack_index(the_repository)) {
> > -		uint32_t i;
> >  		struct multi_pack_index *m =
> >  			get_local_multi_pack_index(the_repository);
> >
> > -		ALLOC_ARRAY(midx_pack_names, m->num_packs);
> > -		for (i = 0; i < m->num_packs; i++)
> > -			midx_pack_names[midx_pack_names_nr++] = xstrdup(m->pack_names[i]);
> > +		ALLOC_ARRAY(midx_pack_names,
> > +			    m->num_packs + m->num_packs_in_base);
> > +
> > +		for (; m; m = m->base_midx)
> > +			for (uint32_t i = 0; i < m->num_packs; i++)
> > +				midx_pack_names[midx_pack_names_nr++] =
> > +					xstrdup(m->pack_names[i]);
> >  	}
> >
> >  	close_object_store(the_repository->objects);
> > --- >8 ---
>
> And this fix looks reasonable to me. It is a bit unfortunate that the
> incremental midx concept bleeds all the way out to callers like this,
> because it means we might have the same problem in other spots. But that
> is nothing new, and I'm not sure of a good solution. If the
> public-facing API pretended as if "struct multi_pack_midx" contained the
> packs for all of the sub-midx entries of the chain, that would solve it.
> But then all of the internal parts of the code that look at the
> incremental entries would need a separate representation. And I suspect
> there's a lot more code in that latter group than the former (most
> callers won't be this intimate with the midx, and just want to convert
> an oid to a pack/offset pair).
>
> Would we want a test to cover this case? We do catch it in the
> linux-TEST-vars build, but it might be nice to have coverage in normal
> test runs. I'm not sure how much of a pain that would be.

I thought quite a bit about this and decided against it. The extra test would really just be this on top:

--- 8< ---
diff --git a/t/t7704-repack-cruft.sh b/t/t7704-repack-cruft.sh
index aa2e2e6ad8..9b71387325 100755
--- a/t/t7704-repack-cruft.sh
+++ b/t/t7704-repack-cruft.sh
@@ -842,7 +842,9 @@ test_expect_success 'repack --write-midx includes cruft when already geometric'
 		# actually write a new object and subsequently a new
 		# pack to contain it.
 		git merge --no-ff $C &&
-		git repack -d &&
+		GIT_TEST_MULTI_PACK_INDEX=1 \
+		GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL=1 \
+			git repack -d &&

 		ls $packdir/pack-*.idx | sort >packs.all &&
 		cruft="$(ls $packdir/pack-*.mtimes)" &&
--- >8 ---

, to force us to put the cruft pack in an earlier MIDX layer. But that
felt like making this test too-specific to incremental MIDXs when the
original test has very little to do with incremental- vs non-incremental
MIDXs.

I tried to write a smaller test case that demonstrates the problem but
couldn't find a straightforward way to minimize the reproduction. As an
alternative, we could duplicate and/or parameterize the test entirely,
but that felt like overkill.

Thanks,
Taylor
Previous: Jeff KingNext: Taylor Blau
Message 87 of 105 in “repack: avoid MIDX'ing cruft pack(s) where possible”
  1. 0/8 repack: avoid MIDX'ing cruft pack(s) where possibleTaylor Blau, Apr 11, 2025
  2. 1/8 pack-objects: use standard option incompatibility functionsTaylor Blau, Apr 11, 2025
  3. 2/8 pack-objects: limit scope in 'add_object_entry_from_pack()'Taylor Blau, Apr 11, 2025
  4. 3/8 pack-objects: factor out handling '--stdin-packs'Taylor Blau, Apr 11, 2025
  5. 4/8 pack-objects: declare 'rev_info' for '--stdin-packs' earlierTaylor Blau, Apr 11, 2025
  6. 5/8 pack-objects: perform name-hash traversal for unpacked objectsTaylor Blau, Apr 11, 2025
  7. 6/8 pack-objects: introduce '--stdin-packs=follow'Taylor Blau, Apr 11, 2025
  8. 7/8 repack: keep track of existing MIDX'd packsTaylor Blau, Apr 11, 2025
  9. 8/8 repack: exclude cruft pack(s) from the MIDX where possibleTaylor Blau, Apr 11, 2025
  10. 0/8 repack: avoid MIDX'ing cruft pack(s) where possibleTaylor Blau, Apr 14, 2025
  11. 1/8 pack-objects: use standard option incompatibility functionsTaylor Blau, Apr 14, 2025
  12. Junio C HamanoApr 14, 2025
  13. Taylor BlauApr 15, 2025
  14. Junio C HamanoApr 15, 2025
  15. Taylor BlauApr 15, 2025
  16. 2/8 object-store-ll.h: add note about designated initializersTaylor Blau, Apr 14, 2025
  17. Junio C HamanoApr 14, 2025
  18. Taylor BlauApr 15, 2025
  19. Elijah NewrenApr 15, 2025
  20. Taylor BlauApr 15, 2025
  21. 3/8 pack-objects: limit scope in 'add_object_entry_from_pack()'Taylor Blau, Apr 14, 2025
  22. Elijah NewrenApr 15, 2025
  23. 4/8 pack-objects: factor out handling '--stdin-packs'Taylor Blau, Apr 14, 2025
  24. 5/8 pack-objects: declare 'rev_info' for '--stdin-packs' earlierTaylor Blau, Apr 14, 2025
  25. 6/8 pack-objects: perform name-hash traversal for unpacked objectsTaylor Blau, Apr 14, 2025
  26. Elijah NewrenApr 15, 2025
  27. Taylor BlauApr 15, 2025
  28. 7/8 pack-objects: introduce '--stdin-packs=follow'Taylor Blau, Apr 14, 2025
  29. Elijah NewrenApr 15, 2025
  30. Taylor BlauApr 15, 2025
  31. Elijah NewrenApr 16, 2025
  32. 8/8 repack: exclude cruft pack(s) from the MIDX where possibleTaylor Blau, Apr 14, 2025
  33. Elijah NewrenApr 15, 2025
  34. Taylor BlauApr 15, 2025
  35. Elijah NewrenApr 15, 2025
  36. Taylor BlauApr 15, 2025
  37. 0/9 repack: avoid MIDX'ing cruft pack(s) where possibleTaylor Blau, Apr 15, 2025
  38. 1/9 pack-objects: use standard option incompatibility functionsTaylor Blau, Apr 15, 2025
  39. 2/9 pack-objects: limit scope in 'add_object_entry_from_pack()'Taylor Blau, Apr 15, 2025
  40. Junio C HamanoApr 16, 2025
  41. Taylor BlauApr 16, 2025
  42. Elijah NewrenApr 16, 2025
  43. Taylor BlauApr 16, 2025
  44. 3/9 pack-objects: factor out handling '--stdin-packs'Taylor Blau, Apr 15, 2025
  45. Junio C HamanoApr 16, 2025
  46. 4/9 pack-objects: declare 'rev_info' for '--stdin-packs' earlierTaylor Blau, Apr 15, 2025
  47. 5/9 pack-objects: perform name-hash traversal for unpacked objectsTaylor Blau, Apr 15, 2025
  48. Junio C HamanoApr 16, 2025
  49. 6/9 pack-objects: fix typo in 'show_object_pack_hint()'Taylor Blau, Apr 15, 2025
  50. Elijah NewrenApr 16, 2025
  51. 7/9 pack-objects: swap 'show_{object,commit}_pack_hint'Taylor Blau, Apr 15, 2025
  52. 8/9 pack-objects: introduce '--stdin-packs=follow'Taylor Blau, Apr 15, 2025
  53. 9/9 repack: exclude cruft pack(s) from the MIDX where possibleTaylor Blau, Apr 15, 2025
  54. Elijah NewrenApr 16, 2025
  55. Taylor BlauApr 16, 2025
  56. Elijah NewrenMay 13, 2025
  57. 0/9 repack: avoid MIDX'ing cruft pack(s) where possibleTaylor Blau, May 28, 2025
  58. 1/9 pack-objects: use standard option incompatibility functionsTaylor Blau, May 28, 2025
  59. 2/9 pack-objects: limit scope in 'add_object_entry_from_pack()'Taylor Blau, May 28, 2025
  60. 3/9 pack-objects: factor out handling '--stdin-packs'Taylor Blau, May 28, 2025
  61. 4/9 pack-objects: declare 'rev_info' for '--stdin-packs' earlierTaylor Blau, May 28, 2025
  62. 5/9 pack-objects: perform name-hash traversal for unpacked objectsTaylor Blau, May 28, 2025
  63. 6/9 pack-objects: fix typo in 'show_object_pack_hint()'Taylor Blau, May 28, 2025
  64. 7/9 pack-objects: swap 'show_{object,commit}_pack_hint'Taylor Blau, May 28, 2025
  65. 8/9 pack-objects: introduce '--stdin-packs=follow'Taylor Blau, May 28, 2025
  66. 9/9 repack: exclude cruft pack(s) from the MIDX where possibleTaylor Blau, May 28, 2025
  67. Carlo Marcelo Arenas BelónJun 19, 2025
  68. fixup! repack: exclude cruft pack(s) from the MIDX where possibleCarlo Marcelo Arenas Belón, Jun 19, 2025
  69. Junio C HamanoJun 19, 2025
  70. Taylor BlauJun 19, 2025
  71. Taylor BlauMay 29, 2025
  72. Elijah NewrenMay 29, 2025
  73. 0/9 repack: avoid MIDX'ing cruft pack(s) where possibleTaylor Blau, Jun 19, 2025
  74. 1/9 pack-objects: use standard option incompatibility functionsTaylor Blau, Jun 19, 2025
  75. 2/9 pack-objects: limit scope in 'add_object_entry_from_pack()'Taylor Blau, Jun 19, 2025
  76. 3/9 pack-objects: factor out handling '--stdin-packs'Taylor Blau, Jun 19, 2025
  77. 4/9 pack-objects: declare 'rev_info' for '--stdin-packs' earlierTaylor Blau, Jun 19, 2025
  78. 5/9 pack-objects: perform name-hash traversal for unpacked objectsTaylor Blau, Jun 19, 2025
  79. 6/9 pack-objects: fix typo in 'show_object_pack_hint()'Taylor Blau, Jun 19, 2025
  80. 7/9 pack-objects: swap 'show_{object,commit}_pack_hint'Taylor Blau, Jun 19, 2025
  81. 8/9 pack-objects: introduce '--stdin-packs=follow'Taylor Blau, Jun 19, 2025
  82. Junio C HamanoJun 20, 2025
  83. 9/9 repack: exclude cruft pack(s) from the MIDX where possibleTaylor Blau, Jun 19, 2025
  84. Jeff KingJun 21, 2025
  85. Taylor BlauJun 23, 2025
  86. Jeff KingJun 24, 2025
  87. Taylor BlauJun 24, 2025
  88. 0/9 repack: avoid MIDX'ing cruft pack(s) where possibleTaylor Blau, Jun 23, 2025
  89. 1/9 pack-objects: use standard option incompatibility functionsTaylor Blau, Jun 23, 2025
  90. Junio C HamanoJun 24, 2025
  91. Taylor BlauJun 24, 2025
  92. 2/9 pack-objects: limit scope in 'add_object_entry_from_pack()'Taylor Blau, Jun 23, 2025
  93. Junio C HamanoJun 23, 2025
  94. 3/9 pack-objects: factor out handling '--stdin-packs'Taylor Blau, Jun 23, 2025
  95. 4/9 pack-objects: declare 'rev_info' for '--stdin-packs' earlierTaylor Blau, Jun 23, 2025
  96. Junio C HamanoJun 23, 2025
  97. 5/9 pack-objects: perform name-hash traversal for unpacked objectsTaylor Blau, Jun 23, 2025
  98. Junio C HamanoJun 23, 2025
  99. Taylor BlauJun 24, 2025
  100. 6/9 pack-objects: fix typo in 'show_object_pack_hint()'Taylor Blau, Jun 23, 2025
  101. 7/9 pack-objects: swap 'show_{object,commit}_pack_hint'Taylor Blau, Jun 23, 2025
  102. 8/9 pack-objects: introduce '--stdin-packs=follow'Taylor Blau, Jun 23, 2025
  103. Junio C HamanoJun 23, 2025
  104. Taylor BlauJun 24, 2025
  105. 9/9 repack: exclude cruft pack(s) from the MIDX where possibleTaylor Blau, Jun 23, 2025

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.