{"thread":{"id":"58945","subject":"[PATCH] object-file: inline write_buffer()","startedAt":"2022-12-13T19:35:18Z","lastAt":"2022-12-13T19:35:18Z","messageCount":1,"participants":["René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"468996","messageId":"94dff140-489c-40b2-7212-201ed3b7d008@web.de","threadId":"58945","inReplyTo":null,"subject":"[PATCH] object-file: inline write_buffer()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2022-12-13T19:35:07Z","receivedAt":"2022-12-13T19:35:18Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"write_buffer() reports the OS error if it is unable to write.  Its only\ncaller dies in that case, giving some more context in its last message.\n\nInline this function and show only a single error message that includes\nboth the context (writing a loose object file) and the OS error.  This\nshortens the code and simplifies the output.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n object-file.c | 11 ++---------\n 1 file changed, 2 insertions(+), 9 deletions(-)\n\ndiff --git a/object-file.c b/object-file.c\nindex 26290554bb..c1b71c2834 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -1864,13 +1864,6 @@ int finalize_object_file(const char *tmpfile, const char *filename)\n \treturn 0;\n }\n\n-static int write_buffer(int fd, const void *buf, size_t len)\n-{\n-\tif (write_in_full(fd, buf, len) < 0)\n-\t\treturn error_errno(_(\"file write error\"));\n-\treturn 0;\n-}\n-\n static void hash_object_file_literally(const struct git_hash_algo *algo,\n \t\t\t\t       const void *buf, unsigned long len,\n \t\t\t\t       const char *type, struct object_id *oid)\n@@ -2015,8 +2008,8 @@ static int write_loose_object_common(git_hash_ctx *c,\n\n \tret = git_deflate(stream, flush ? Z_FINISH : 0);\n \tthe_hash_algo->update_fn(c, in0, stream->next_in - in0);\n-\tif (write_buffer(fd, compressed, stream->next_out - compressed) < 0)\n-\t\tdie(_(\"unable to write loose object file\"));\n+\tif (write_in_full(fd, compressed, stream->next_out - compressed) < 0)\n+\t\tdie_errno(_(\"unable to write loose object file\"));\n \tstream->next_out = compressed;\n \tstream->avail_out = compressed_len;\n\n--\n2.39.0\n"}]}