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

[RFC PATCH 01/10] repack: unconditionally exclude non-kept packs

From
Taylor Blau <me@ttaylorr.com>
Date
Jun 26, 2026, 19:02 UTC
Message-ID
<7e607b7b64eb347dbf92a0dee3883aaa34bbb177.1782500507.git.me@ttaylorr.com>
In-Reply-To
<cover.1782500507.git.me@ttaylorr.com>

In `write_cruft_pack()`, we handle excluding objects found in non-kept packs from being included in the cruft pack via two code paths:

 * When using '--combine-cruft-below-size' (provided that we are not
   expiring cruft objects), we use the aptly-named
   `combine_small_cruft_packs()` function.
 * In all other cases, we handle it directly in the 'else' branch of the
   same conditional.

Simplify this by moving the non-kept pack exclusion out of the conditional entirely, so that non-kept packs are always excluded regardless of whether we are combining small cruft packs or not.

This is a preparatory refactor for a subsequent change that will use the pack_geometry struct when available to determine which non-kept packs to exclude.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 repack-cruft.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/repack-cruft.c b/repack-cruft.c
index 0653e887923..6a040e98017 100644
--- a/repack-cruft.c
+++ b/repack-cruft.c
@@ -9,7 +9,6 @@ static void combine_small_cruft_packs(FILE *in, off_t combine_cruft_below_size,
 {
 	struct packed_git *p;
 	struct strbuf buf = STRBUF_INIT;
-	size_t i;
 
 	repo_for_each_pack(existing->repo, p) {
 		if (!(p->is_cruft && p->pack_local))
@@ -30,10 +29,6 @@ static void combine_small_cruft_packs(FILE *in, off_t combine_cruft_below_size,
 		}
 	}
 
-	for (i = 0; i < existing->non_kept_packs.nr; i++)
-		fprintf(in, "-%s.pack\n",
-			existing->non_kept_packs.items[i].string);
-
 	strbuf_release(&buf);
 }
 
@@ -80,15 +75,14 @@ int write_cruft_pack(const struct write_pack_opts *opts,
 	in = xfdopen(cmd.in, "w");
 	for_each_string_list_item(item, names)
 		fprintf(in, "%s-%s.pack\n", pack_prefix, item->string);
-	if (combine_cruft_below_size && !cruft_expiration) {
+	if (combine_cruft_below_size && !cruft_expiration)
 		combine_small_cruft_packs(in, combine_cruft_below_size,
 					  existing);
-	} else {
-		for_each_string_list_item(item, &existing->non_kept_packs)
-			fprintf(in, "-%s.pack\n", item->string);
+	else
 		for_each_string_list_item(item, &existing->cruft_packs)
 			fprintf(in, "-%s.pack\n", item->string);
-	}
+	for_each_string_list_item(item, &existing->non_kept_packs)
+		fprintf(in, "-%s.pack\n", item->string);
 	for_each_string_list_item(item, &existing->kept_packs)
 		fprintf(in, "%s.pack\n", item->string);
 	fclose(in);
-- 
2.55.0.rc2.10.g29e31820dce
Previous: Taylor BlauNext: Taylor Blau
Message 2 of 18 in “repack: combine '--geometric' and '--cruft'”
  1. 00/10 repack: combine '--geometric' and '--cruft'Taylor Blau, Jun 26, 2026
  2. 01/10 repack: unconditionally exclude non-kept packsTaylor Blau, Jun 26, 2026
  3. 03/10 repack: mark geometric progression of packs as retainedTaylor Blau, Jun 26, 2026
  4. 04/10 repack: teach MIDX retention about geometric rollupsTaylor Blau, Jun 26, 2026
  5. Junio C HamanoJun 26, 2026
  6. Taylor BlauJun 27, 2026
  7. 05/10 repack: delete geometric packs via existing_packsTaylor Blau, Jun 26, 2026
  8. 06/10 repack-geometry: drop unused redundant-pack removalTaylor Blau, Jun 26, 2026
  9. 02/10 repack: extract `locate_existing_pack()` helperTaylor Blau, Jun 26, 2026
  10. 07/10 pack-objects: extract `stdin_packs_add_all_pack_entries()`Taylor Blau, Jun 26, 2026
  11. 08/10 pack-objects: introduce '--stdin-packs=follow-reachable'Taylor Blau, Jun 26, 2026
  12. Junio C HamanoJun 26, 2026
  13. Taylor BlauJun 27, 2026
  14. Junio C HamanoJun 27, 2026
  15. Taylor BlauJun 27, 2026
  16. 09/10 pack-objects: support '--refs-snapshot' with 'follow-reachable'Taylor Blau, Jun 26, 2026
  17. 10/10 repack: support combining '--geometric' with '--cruft'Taylor Blau, Jun 26, 2026
  18. Junio C HamanoJul 27, 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.