From 0578f1e66aa381356bfe2f53decf3864d88d23d3 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 31 Jan 2025 13:55:31 +0100 Subject: 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 Signed-off-by: Junio C Hamano --- http.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'http.c') diff --git a/http.c b/http.c index f08b2ae474..f4504133e8 100644 --- a/http.c +++ b/http.c @@ -2597,8 +2597,8 @@ static size_t fwrite_sha1_file(char *ptr, size_t eltsize, size_t nmemb, freq->stream.next_out = expn; freq->stream.avail_out = sizeof(expn); freq->zret = git_inflate(&freq->stream, Z_SYNC_FLUSH); - the_hash_algo->update_fn(&freq->c, expn, - sizeof(expn) - freq->stream.avail_out); + git_hash_update(&freq->c, expn, + sizeof(expn) - freq->stream.avail_out); } while (freq->stream.avail_in && freq->zret == Z_OK); return nmemb; } @@ -2763,7 +2763,7 @@ int finish_http_object_request(struct http_object_request *freq) return -1; } - the_hash_algo->final_oid_fn(&freq->real_oid, &freq->c); + git_hash_final_oid(&freq->real_oid, &freq->c); if (freq->zret != Z_STREAM_END) { unlink_or_warn(freq->tmpfile.buf); return -1; -- cgit v1.3