aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/unpack-objects.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-01-31 13:55:31 +0100
committerJunio C Hamano <gitster@pobox.com>2025-01-31 10:06:11 -0800
commit0578f1e66aa381356bfe2f53decf3864d88d23d3 (patch)
treeca26e9efacec048463fe529f72998ba59924f479 /builtin/unpack-objects.c
parentb2755c15e2359c5436de062bf33a155a99c72c03 (diff)
downloadgit-0578f1e66aa381356bfe2f53decf3864d88d23d3.tar.gz
global: adapt callers to use generic hash context helpers
Adapt callers to use generic hash context helpers instead of using the hash algorithm to update them. This makes the callsites easier to reason about and removes the possibility that the wrong hash algorithm is used to update the hash context's state. And as a nice side effect this also gets rid of a bunch of users of `the_hash_algo`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/unpack-objects.c')
-rw-r--r--builtin/unpack-objects.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index d72885510c..8383bcf404 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -70,7 +70,7 @@ static void *fill(int min)
if (min > sizeof(buffer))
die("cannot fill %d bytes", min);
if (offset) {
- the_hash_algo->update_fn(&ctx, buffer, offset);
+ git_hash_update(&ctx, buffer, offset);
memmove(buffer, buffer + offset, len);
offset = 0;
}
@@ -667,10 +667,9 @@ int cmd_unpack_objects(int argc,
}
the_hash_algo->init_fn(&ctx);
unpack_all();
- the_hash_algo->update_fn(&ctx, buffer, offset);
- the_hash_algo->init_fn(&tmp_ctx);
- the_hash_algo->clone_fn(&tmp_ctx, &ctx);
- the_hash_algo->final_oid_fn(&oid, &tmp_ctx);
+ git_hash_update(&ctx, buffer, offset);
+ git_hash_clone(&tmp_ctx, &ctx);
+ git_hash_final_oid(&oid, &tmp_ctx);
if (strict) {
write_rest();
if (fsck_finish(&fsck_options))