object-file: inline write_buffer()

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>

René Scharfe committed Dec 13, 2022 at 20:35 UTC d422d06167af35bbe81026ee75c14eaa6b93127c
1 file changed +2 -9
object-file.c
+2 -9
@@ -1864,13 +1864,6 @@ out:
1864 return 0;
1865 }
1866
1867 -static int write_buffer(int fd, const void *buf, size_t len)
1868 -{
1869 - if (write_in_full(fd, buf, len) < 0)
1870 - return error_errno(_("file write error"));
1871 - return 0;
1872 -}
1873 -
1867 static void hash_object_file_literally(const struct git_hash_algo *algo,
1868 const void *buf, unsigned long len,
1869 const char *type, struct object_id *oid)
@@ -2015,8 +2008,8 @@ static int write_loose_object_common(git_hash_ctx *c,
2008
2009 ret = git_deflate(stream, flush ? Z_FINISH : 0);
2010 the_hash_algo->update_fn(c, in0, stream->next_in - in0);
2018 - if (write_buffer(fd, compressed, stream->next_out - compressed) < 0)
2019 - die(_("unable to write loose object file"));
2011 + if (write_in_full(fd, compressed, stream->next_out - compressed) < 0)
2012 + die_errno(_("unable to write loose object file"));
2013 stream->next_out = compressed;
2014 stream->avail_out = compressed_len;
2015