mirror of
https://github.com/git/git.git
synced 2024-11-24 02:17:02 +08:00
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>
This commit is contained in:
parent
ef22318cff
commit
ee861e0f78
@ -644,9 +644,7 @@ void write_file(const char *path, const char *fmt, ...)
|
|||||||
{
|
{
|
||||||
va_list params;
|
va_list params;
|
||||||
struct strbuf sb = STRBUF_INIT;
|
struct strbuf sb = STRBUF_INIT;
|
||||||
int fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666);
|
int fd = xopen(path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||||
if (fd < 0)
|
|
||||||
die_errno(_("could not open %s for writing"), path);
|
|
||||||
|
|
||||||
va_start(params, fmt);
|
va_start(params, fmt);
|
||||||
strbuf_vaddf(&sb, fmt, params);
|
strbuf_vaddf(&sb, fmt, params);
|
||||||
|
Loading…
Reference in New Issue
Block a user