diff options
author | Jeff King <peff@peff.net> | 2019-01-07 11:34:40 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-01-08 20:40:19 +0300 |
commit | f0be0db13dbd2d96d2240374e0e9cb106bf6a614 (patch) | |
tree | 147863f80da336ff3108e84d1e5c4b37a167cb97 /http.c | |
parent | c93206b412dade4e480588ad5902f4b950d908ab (diff) |
http: use struct object_id instead of bare sha1
The dumb-http walker code still passes around and stores object ids as
"unsigned char *sha1". Let's modernize it.
There's probably still more work to be done to handle dumb-http fetches
with a new, larger hash. But that can wait; this is enough that we can
now convert some of the low-level object routines that we call into from
here (and in fact, some of the "oid.hash" references added here will be
further improved in the next patch).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http.c')
-rw-r--r-- | http.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -2337,9 +2337,9 @@ static size_t fwrite_sha1_file(char *ptr, size_t eltsize, size_t nmemb, } struct http_object_request *new_http_object_request(const char *base_url, - unsigned char *sha1) + const struct object_id *oid) { - char *hex = sha1_to_hex(sha1); + char *hex = oid_to_hex(oid); struct strbuf filename = STRBUF_INIT; struct strbuf prevfile = STRBUF_INIT; int prevlocal; @@ -2350,10 +2350,10 @@ struct http_object_request *new_http_object_request(const char *base_url, freq = xcalloc(1, sizeof(*freq)); strbuf_init(&freq->tmpfile, 0); - hashcpy(freq->sha1, sha1); + oidcpy(&freq->oid, oid); freq->localfile = -1; - loose_object_path(the_repository, &filename, sha1); + loose_object_path(the_repository, &filename, oid->hash); strbuf_addf(&freq->tmpfile, "%s.temp", filename.buf); strbuf_addf(&prevfile, "%s.prev", filename.buf); @@ -2495,16 +2495,16 @@ int finish_http_object_request(struct http_object_request *freq) } git_inflate_end(&freq->stream); - git_SHA1_Final(freq->real_sha1, &freq->c); + git_SHA1_Final(freq->real_oid.hash, &freq->c); if (freq->zret != Z_STREAM_END) { unlink_or_warn(freq->tmpfile.buf); return -1; } - if (!hasheq(freq->sha1, freq->real_sha1)) { + if (!oideq(&freq->oid, &freq->real_oid)) { unlink_or_warn(freq->tmpfile.buf); return -1; } - loose_object_path(the_repository, &filename, freq->sha1); + loose_object_path(the_repository, &filename, freq->oid.hash); freq->rename = finalize_object_file(freq->tmpfile.buf, filename.buf); strbuf_release(&filename); |