summaryrefslogtreecommitdiff
path: root/builtin/bugreport.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2021-08-25 22:16:46 +0200
committerJunio C Hamano <gitster@pobox.com>2021-08-25 14:39:08 -0700
commit66e905b7dd0f4e9dd576be681f30fbaeeb19ec4a (patch)
tree4cff22e9d61be87fc5bce6952981e8ba1c7b7127 /builtin/bugreport.c
parenta7439d0f9dd291e7cc9e6c2dda19cbfdf09b62ee (diff)
downloadgit-66e905b7dd0f4e9dd576be681f30fbaeeb19ec4a.tar.gz
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/bugreport.c')
-rw-r--r--builtin/bugreport.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/builtin/bugreport.c b/builtin/bugreport.c
index 9915a5841d..06ed10dc92 100644
--- a/builtin/bugreport.c
+++ b/builtin/bugreport.c
@@ -171,10 +171,7 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix)
get_populated_hooks(&buffer, !startup_info->have_repository);
/* fopen doesn't offer us an O_EXCL alternative, except with glibc. */
- report = open(report_path.buf, O_CREAT | O_EXCL | O_WRONLY, 0666);
-
- if (report < 0)
- die(_("couldn't create a new file at '%s'"), report_path.buf);
+ report = xopen(report_path.buf, O_CREAT | O_EXCL | O_WRONLY, 0666);
if (write_in_full(report, buffer.buf, buffer.len) < 0)
die_errno(_("unable to write to %s"), report_path.buf);