diff options
author | René Scharfe <l.s.r@web.de> | 2021-08-25 22:16:46 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-08-25 14:39:08 -0700 |
commit | 66e905b7dd0f4e9dd576be681f30fbaeeb19ec4a (patch) | |
tree | 4cff22e9d61be87fc5bce6952981e8ba1c7b7127 /builtin/notes.c | |
parent | xopen: explicitly report creation failures (diff) | |
download | tgif-66e905b7dd0f4e9dd576be681f30fbaeeb19ec4a.tar.xz |
use xopen() to handle fatal open(2) failures
Add and apply a semantic patch for using xopen() instead of calling
open(2) and die() or die_errno() explicitly. This makes the error
messages more consistent and shortens the code.
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/notes.c')
-rw-r--r-- | builtin/notes.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/builtin/notes.c b/builtin/notes.c index 74bba39ca8..71c59583a1 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -172,9 +172,7 @@ static void prepare_note_data(const struct object_id *object, struct note_data * /* write the template message before editing: */ d->edit_path = git_pathdup("NOTES_EDITMSG"); - fd = open(d->edit_path, O_CREAT | O_TRUNC | O_WRONLY, 0600); - if (fd < 0) - die_errno(_("could not create file '%s'"), d->edit_path); + fd = xopen(d->edit_path, O_CREAT | O_TRUNC | O_WRONLY, 0600); if (d->given) write_or_die(fd, d->buf.buf, d->buf.len); |