Skip to content

Commit d422d06

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c48035d commit d422d06

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

object-file.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,13 +1864,6 @@ int finalize_object_file(const char *tmpfile, const char *filename)
18641864
return 0;
18651865
}
18661866

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-
18741867
static void hash_object_file_literally(const struct git_hash_algo *algo,
18751868
const void *buf, unsigned long len,
18761869
const char *type, struct object_id *oid)
@@ -2015,8 +2008,8 @@ static int write_loose_object_common(git_hash_ctx *c,
20152008

20162009
ret = git_deflate(stream, flush ? Z_FINISH : 0);
20172010
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"));
20202013
stream->next_out = compressed;
20212014
stream->avail_out = compressed_len;
20222015

0 commit comments

Comments
 (0)