builtin/repack.c: avoid "the_hash_algo" when deleting packs
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 <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
Oct 15, 2025 at 18:27 UTC
3758052c0f43fd01d25fc7381c7939daba66c015
1 file changed
+6
-4
builtin/repack.c
+6
-4
@@ -168,11 +168,12 @@ static int pack_is_retained(struct string_list_item *item)
168
return (uintptr_t)item->util & RETAIN_PACK;
169
}
170
171
-static void mark_packs_for_deletion_1(struct string_list *names,
171
+static void mark_packs_for_deletion_1(const struct git_hash_algo *algop,
172
+ struct string_list *names,
173
struct string_list *list)
174
{
175
struct string_list_item *item;
175
- const int hexsz = the_hash_algo->hexsz;
176
+ const int hexsz = algop->hexsz;
177
178
for_each_string_list_item(item, list) {
179
char *sha1;
@@ -217,8 +218,9 @@ static void mark_packs_for_deletion(struct existing_packs *existing,
218
struct string_list *names)
219
220
{
220
- mark_packs_for_deletion_1(names, &existing->non_kept_packs);
221
- mark_packs_for_deletion_1(names, &existing->cruft_packs);
221
+ const struct git_hash_algo *algop = existing->repo->hash_algo;
222
+ mark_packs_for_deletion_1(algop, names, &existing->non_kept_packs);
223
+ mark_packs_for_deletion_1(algop, names, &existing->cruft_packs);
224
}
225
226
static void remove_redundant_pack(struct repository *repo,