summaryrefslogtreecommitdiff
path: root/builtin/tag.c
diff options
context:
space:
mode:
authorLibravatar René Scharfe <l.s.r@web.de>2021-08-25 22:16:46 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-08-25 14:39:08 -0700
commit66e905b7dd0f4e9dd576be681f30fbaeeb19ec4a (patch)
tree4cff22e9d61be87fc5bce6952981e8ba1c7b7127 /builtin/tag.c
parentxopen: explicitly report creation failures (diff)
downloadtgif-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/tag.c')
-rw-r--r--builtin/tag.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/builtin/tag.c b/builtin/tag.c
index 82fcfc0982..87552ae6ac 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -293,9 +293,7 @@ static void create_tag(const struct object_id *object, const char *object_ref,
/* write the template message before editing: */
path = git_pathdup("TAG_EDITMSG");
- fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
- if (fd < 0)
- die_errno(_("could not create file '%s'"), path);
+ fd = xopen(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
if (opt->message_given) {
write_or_die(fd, buf->buf, buf->len);