aboutsummaryrefslogtreecommitdiffstats
path: root/builtin
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2025-10-15 18:27:33 -0400
committerJunio C Hamano <gitster@pobox.com>2025-10-16 10:08:53 -0700
commit3758052c0f43fd01d25fc7381c7939daba66c015 (patch)
tree78d07f09d5bb03a47e66da3feb9144e5e6ed6900 /builtin
parentcae9e2abbd8fb2fd483e101275cee15ef27d5953 (diff)
downloadgit-3758052c0f43fd01d25fc7381c7939daba66c015.tar.gz
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>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/repack.c10
1 files 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,