diff options
author | Jeff King <peff@peff.net> | 2016-07-08 05:10:08 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-07-08 09:47:29 -0700 |
commit | ee861e0f78367ff0e94feeb42f721ef83ceec251 (patch) | |
tree | cd8b5a9aa1f345246ae1657bfe238df3a35705f8 /wrapper.c | |
parent | ef22318cff51244cd0047b11ee7accfded522782 (diff) | |
download | git-ee861e0f78367ff0e94feeb42f721ef83ceec251.tar.gz |
write_file: use xopen
This simplifies the code a tiny bit, and provides consistent
error messages with other users of xopen().
While we're here, let's also switch to using O_WRONLY. We
know we're only going to open/write/close the file, so
there's no point in asking for O_RDWR.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wrapper.c')
-rw-r--r-- | wrapper.c | 4 |
1 files changed, 1 insertions, 3 deletions
@@ -644,9 +644,7 @@ void write_file(const char *path, const char *fmt, ...) { va_list params; struct strbuf sb = STRBUF_INIT; - int fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666); - if (fd < 0) - die_errno(_("could not open %s for writing"), path); + int fd = xopen(path, O_WRONLY | O_CREAT | O_TRUNC, 0666); va_start(params, fmt); strbuf_vaddf(&sb, fmt, params); |