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>
This commit is contained in:
committed by
Junio C Hamano
parent
b2755c15e2
commit
0578f1e66a
6
http.c
6
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;
|
||||
|
||||
Reference in New Issue
Block a user