From b69fb867b4bb9e30e705d2176fe8a0a90b208325 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 12 Nov 2018 09:48:56 -0500 Subject: sha1_file_name(): overwrite buffer instead of appending The sha1_file_name() function is used to generate the path to a loose object in the object directory. It doesn't make much sense for it to append, since the the path we write may be absolute (i.e., you cannot reliably build up a path with it). Because many callers use it with a static buffer, they have to strbuf_reset() manually before each call (and the other callers always use an empty buffer, so they don't care either way). Let's handle this automatically. Since we're changing the semantics, let's take the opportunity to give it a more hash-neutral name (which will also catch any callers from topics in flight). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'http.c') diff --git a/http.c b/http.c index 3dc8c560d6..46c2e7a275 100644 --- a/http.c +++ b/http.c @@ -2314,7 +2314,7 @@ struct http_object_request *new_http_object_request(const char *base_url, hashcpy(freq->sha1, sha1); freq->localfile = -1; - sha1_file_name(the_repository, &filename, sha1); + loose_object_path(the_repository, &filename, sha1); strbuf_addf(&freq->tmpfile, "%s.temp", filename.buf); strbuf_addf(&prevfile, "%s.prev", filename.buf); @@ -2465,7 +2465,7 @@ int finish_http_object_request(struct http_object_request *freq) unlink_or_warn(freq->tmpfile.buf); return -1; } - sha1_file_name(the_repository, &filename, freq->sha1); + loose_object_path(the_repository, &filename, freq->sha1); freq->rename = finalize_object_file(freq->tmpfile.buf, filename.buf); strbuf_release(&filename); -- cgit v1.2.3