summaryrefslogtreecommitdiff
path: root/builtin/commit-tree.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2021-08-25 20:16:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-08-25 21:39:08 (GMT)
commit66e905b7dd0f4e9dd576be681f30fbaeeb19ec4a (patch)
tree4cff22e9d61be87fc5bce6952981e8ba1c7b7127 /builtin/commit-tree.c
parenta7439d0f9dd291e7cc9e6c2dda19cbfdf09b62ee (diff)
downloadgit-66e905b7dd0f4e9dd576be681f30fbaeeb19ec4a.zip
git-66e905b7dd0f4e9dd576be681f30fbaeeb19ec4a.tar.gz
git-66e905b7dd0f4e9dd576be681f30fbaeeb19ec4a.tar.bz2
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/commit-tree.c')
-rw-r--r--builtin/commit-tree.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index 1031b9a..63ea322 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -88,9 +88,7 @@ static int parse_file_arg_callback(const struct option *opt,
if (!strcmp(arg, "-"))
fd = 0;
else {
- fd = open(arg, O_RDONLY);
- if (fd < 0)
- die_errno(_("git commit-tree: failed to open '%s'"), arg);
+ fd = xopen(arg, O_RDONLY);
}
if (strbuf_read(buf, fd, 0) < 0)
die_errno(_("git commit-tree: failed to read '%s'"), arg);