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/index-pack.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/index-pack.c')
-rw-r--r-- | builtin/index-pack.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 8336466865..6cc4890217 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -338,15 +338,11 @@ static const char *open_pack_file(const char *pack_name) "pack/tmp_pack_XXXXXX"); pack_name = strbuf_detach(&tmp_file, NULL); } else { - output_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600); - if (output_fd < 0) - die_errno(_("unable to create '%s'"), pack_name); + output_fd = xopen(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600); } nothread_data.pack_fd = output_fd; } else { - input_fd = open(pack_name, O_RDONLY); - if (input_fd < 0) - die_errno(_("cannot open packfile '%s'"), pack_name); + input_fd = xopen(pack_name, O_RDONLY); output_fd = -1; nothread_data.pack_fd = input_fd; } |