Thread (158 messages) 158 messages, 3 authors, 2025-10-16
STALE250d

[PATCH 06/49] builtin/repack.c: avoid "the_hash_algo" when deleting packs

From: Taylor Blau <hidden>
Date: 2025-09-28 22:07:36
Subsystem: the rest · Maintainer: Linus Torvalds

The "mark_packs_for_deletion_1" function uses "the_hash_algo->hexsz" to
isolate a pack's checksum before deleting it to avoid deleting a newly
written pack having the same checksum (that is, some generated pack
wound up identical to an existing pack).

Avoid this by passing down a "struct git_hash_algo" pointer, and refer to
the hash algorithm through it instead.

Signed-off-by: Taylor Blau <redacted>
---
 builtin/repack.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/builtin/repack.c b/builtin/repack.c
index 4f08b57ddb..094f5a0cc2 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -168,11 +168,12 @@ static int pack_is_retained(struct string_list_item *item)
 	return (uintptr_t)item->util & RETAIN_PACK;
 }
 
-static void mark_packs_for_deletion_1(struct string_list *names,
+static void mark_packs_for_deletion_1(const struct git_hash_algo *algop,
+				      struct string_list *names,
 				      struct string_list *list)
 {
 	struct string_list_item *item;
-	const int hexsz = the_hash_algo->hexsz;
+	const int hexsz = algop->hexsz;
 
 	for_each_string_list_item(item, list) {
 		char *sha1;
@@ -217,8 +218,9 @@ static void mark_packs_for_deletion(struct existing_packs *existing,
 				    struct string_list *names)
 
 {
-	mark_packs_for_deletion_1(names, &existing->non_kept_packs);
-	mark_packs_for_deletion_1(names, &existing->cruft_packs);
+	const struct git_hash_algo *algop = existing->repo->hash_algo;
+	mark_packs_for_deletion_1(algop, names, &existing->non_kept_packs);
+	mark_packs_for_deletion_1(algop, names, &existing->cruft_packs);
 }
 
 static void remove_redundant_pack(struct repository *repo,
-- 
2.51.0.243.g16eca91f2c0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help