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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
263db403fa
commit
b69fb867b4
@@ -547,7 +547,7 @@ static int fetch_object(struct walker *walker, unsigned char *sha1)
|
||||
ret = error("File %s has bad hash", hex);
|
||||
} else if (req->rename < 0) {
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
sha1_file_name(the_repository, &buf, req->sha1);
|
||||
loose_object_path(the_repository, &buf, req->sha1);
|
||||
ret = error("unable to write sha1 filename %s", buf.buf);
|
||||
strbuf_release(&buf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user