]> git.ipfire.org Git - thirdparty/git.git/commitdiff
http: use idempotent git_hash_discard()
authorJeff King <peff@peff.net>
Wed, 8 Jul 2026 03:53:02 +0000 (23:53 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Jul 2026 04:56:00 +0000 (21:56 -0700)
Now that it is OK to call git_hash_discard() even after finalizing the
hash, we no longer need the ctx_valid bool added by a2d8ea5a76 (http:
discard hash in dumb-http http_object_request, 2026-07-02).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
http.c
http.h

diff --git a/http.c b/http.c
index 0341de5031ab20f0737fed8d41e1585c2245a76d..caccf2108e447989decf85cc3434b267c566a144 100644 (file)
--- a/http.c
+++ b/http.c
@@ -2880,7 +2880,6 @@ struct http_object_request *new_http_object_request(const char *base_url,
        git_inflate_init(&freq->stream);
 
        git_hash_init(&freq->c, the_hash_algo);
-       freq->hash_ctx_valid = 1;
 
        freq->url = get_remote_object_url(base_url, hex, 0);
 
@@ -2989,7 +2988,6 @@ int finish_http_object_request(struct http_object_request *freq)
        }
 
        git_hash_final_oid(&freq->real_oid, &freq->c);
-       freq->hash_ctx_valid = 0;
        if (freq->zret != Z_STREAM_END) {
                unlink_or_warn(freq->tmpfile.buf);
                return -1;
@@ -3030,8 +3028,7 @@ void release_http_object_request(struct http_object_request **freq_p)
        curl_slist_free_all(freq->headers);
        strbuf_release(&freq->tmpfile);
        git_inflate_end(&freq->stream);
-       if (freq->hash_ctx_valid)
-               git_hash_discard(&freq->c);
+       git_hash_discard(&freq->c);
 
        free(freq);
        *freq_p = NULL;
diff --git a/http.h b/http.h
index 6b0639150f4b7132f80ebe39e73339dfc748c70c..729c51904d39ad789a016dbcbfdfa3a07fc4fcc8 100644 (file)
--- a/http.h
+++ b/http.h
@@ -255,7 +255,6 @@ struct http_object_request {
        struct object_id oid;
        struct object_id real_oid;
        struct git_hash_ctx c;
-       int hash_ctx_valid;
        git_zstream stream;
        int zret;
        int rename;