]> git.ipfire.org Git - thirdparty/git.git/commitdiff
object-file: inline write_buffer()
authorRené Scharfe <l.s.r@web.de>
Tue, 13 Dec 2022 19:35:07 +0000 (20:35 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Dec 2022 01:29:19 +0000 (10:29 +0900)
write_buffer() reports the OS error if it is unable to write.  Its only
caller dies in that case, giving some more context in its last message.

Inline this function and show only a single error message that includes
both the context (writing a loose object file) and the OS error.  This
shortens the code and simplifies the output.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
object-file.c

index 26290554bb4c5f1d679194fe7d3f2b5c78a273e2..c1b71c2834782d28d2bafad87baf772acd905df9 100644 (file)
@@ -1864,13 +1864,6 @@ out:
        return 0;
 }
 
-static int write_buffer(int fd, const void *buf, size_t len)
-{
-       if (write_in_full(fd, buf, len) < 0)
-               return error_errno(_("file write error"));
-       return 0;
-}
-
 static void hash_object_file_literally(const struct git_hash_algo *algo,
                                       const void *buf, unsigned long len,
                                       const char *type, struct object_id *oid)
@@ -2015,8 +2008,8 @@ static int write_loose_object_common(git_hash_ctx *c,
 
        ret = git_deflate(stream, flush ? Z_FINISH : 0);
        the_hash_algo->update_fn(c, in0, stream->next_in - in0);
-       if (write_buffer(fd, compressed, stream->next_out - compressed) < 0)
-               die(_("unable to write loose object file"));
+       if (write_in_full(fd, compressed, stream->next_out - compressed) < 0)
+               die_errno(_("unable to write loose object file"));
        stream->next_out = compressed;
        stream->avail_out = compressed_len;