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

[RFC PATCH 03/10] repack: mark geometric progression of packs as retained

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

In non-geometric repacks, any packs which repack wishes to delete are handled via the `existing_packs` struct, which has a mechanism to retain would-be-deleted packs (e.g., if we happened to write a new pack identical to one otherwise marked for deletion).

In geometric repacks, repack removes any rewritten packs (alternatively, any packs which were combined in order to restore a geometric progression) by enumerating them via `pack_geometry_remove_redundant()`.

Prepare to use the `existing_packs` deletion machinery for geometric repacks by marking any non-kept packs above the geometric split line as retained. Do the same for promisor packs, which have their own split point.

This commit only records which packs the later deletion pass must keep; it does not change which packs are written or removed.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 builtin/repack.c |  2 ++
 repack.c         | 27 +++++++++++++++++++++++++++
 repack.h         |  3 +++
 3 files changed, 32 insertions(+)
diff --git a/builtin/repack.c b/builtin/repack.c
index 1524a9c13ad..ce979d86d96 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -325,6 +325,8 @@ int cmd_repack(int argc,
 		}
 		pack_geometry_init(&geometry, &existing, &po_args);
 		pack_geometry_split(&geometry);
+
+		existing_packs_retain_from_geometry(&existing, &geometry);
 	}
 
 	prepare_pack_objects(&cmd, &po_args, packtmp);
diff --git a/repack.c b/repack.c
index 986c74ac7e8..9b3cb425431 100644
--- a/repack.c
+++ b/repack.c
@@ -254,6 +254,33 @@ void existing_packs_retain_cruft(struct existing_packs *existing,
 	existing_packs_mark_retained(item);
 }
 
+static void existing_packs_retain_non_kept(struct existing_packs *existing,
+					   struct packed_git *p)
+{
+	struct string_list_item *item;
+
+	if (!p->pack_local)
+		return;
+
+	item = locate_existing_pack(&existing->non_kept_packs, p);
+	if (!item)
+		BUG("could not find non-kept pack '%s'", pack_basename(p));
+
+	existing_packs_mark_retained(item);
+}
+
+void existing_packs_retain_from_geometry(struct existing_packs *existing,
+					 const struct pack_geometry *geometry)
+{
+	uint32_t i;
+
+	for (i = geometry->split; i < geometry->pack_nr; i++)
+		existing_packs_retain_non_kept(existing, geometry->pack[i]);
+	for (i = geometry->promisor_split; i < geometry->promisor_pack_nr; i++)
+		existing_packs_retain_non_kept(existing,
+					       geometry->promisor_pack[i]);
+}
+
 void existing_packs_mark_for_deletion(struct existing_packs *existing,
 				      struct string_list *names)
 
diff --git a/repack.h b/repack.h
index f9fbc895f02..bb4c944d0cb 100644
--- a/repack.h
+++ b/repack.h
@@ -54,6 +54,7 @@ int finish_pack_objects_cmd(const struct git_hash_algo *algop,
 
 struct repository;
 struct packed_git;
+struct pack_geometry;
 
 struct existing_packs {
 	struct repository *repo;
@@ -82,6 +83,8 @@ int existing_packs_has_non_kept(const struct existing_packs *existing);
 int existing_pack_is_marked_for_deletion(struct string_list_item *item);
 void existing_packs_retain_cruft(struct existing_packs *existing,
 				 struct packed_git *cruft);
+void existing_packs_retain_from_geometry(struct existing_packs *existing,
+					 const struct pack_geometry *geometry);
 void existing_packs_mark_for_deletion(struct existing_packs *existing,
 				      struct string_list *names);
 void existing_packs_retain_midx_packs(struct existing_packs *existing);
-- 
2.55.0.rc2.10.g29e31820dce
Previous: Taylor BlauNext: Taylor Blau
Message 3 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.