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/add.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/add.c')
-rw-r--r-- | builtin/add.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/builtin/add.c b/builtin/add.c index 09e684585d..c37c95b45b 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -313,9 +313,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix) rev.diffopt.output_format = DIFF_FORMAT_PATCH; rev.diffopt.use_color = 0; rev.diffopt.flags.ignore_dirty_submodules = 1; - out = open(file, O_CREAT | O_WRONLY | O_TRUNC, 0666); - if (out < 0) - die(_("Could not open '%s' for writing."), file); + out = xopen(file, O_CREAT | O_WRONLY | O_TRUNC, 0666); rev.diffopt.file = xfdopen(out, "w"); rev.diffopt.close_file = 1; if (run_diff_files(&rev, 0)) |