summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-06-13 20:47:09 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-13 20:47:09 (GMT)
commitb9a7d55d938a81eb6268196b789d573437492100 (patch)
tree637c6e3452e5b81394faf99f0a4a24ce73c801e8 /diff.c
parent9743f18f3fef0b77b8715cba256a740a7238f761 (diff)
parente5b313442ab7c700d0851e9dbe7d2b029e3893e5 (diff)
downloadgit-b9a7d55d938a81eb6268196b789d573437492100.zip
git-b9a7d55d938a81eb6268196b789d573437492100.tar.gz
git-b9a7d55d938a81eb6268196b789d573437492100.tar.bz2
Merge branch 'nd/fopen-errors'
We often try to open a file for reading whose existence is optional, and silently ignore errors from open/fopen; report such errors if they are not due to missing files. * nd/fopen-errors: mingw_fopen: report ENOENT for invalid file names mingw: verify that paths are not mistaken for remote nicknames log: fix memory leak in open_next_file() rerere.c: move error_errno() closer to the source system call print errno when reporting a system call error wrapper.c: make warn_on_inaccessible() static wrapper.c: add and use fopen_or_warn() wrapper.c: add and use warn_on_fopen_errors() config.mak.uname: set FREAD_READS_DIRECTORIES for Darwin, too config.mak.uname: set FREAD_READS_DIRECTORIES for Linux and FreeBSD clone: use xfopen() instead of fopen() use xfopen() in more places git_fopen: fix a sparse 'not declared' warning
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/diff.c b/diff.c
index 5275c4b..e35cf6c 100644
--- a/diff.c
+++ b/diff.c
@@ -4071,9 +4071,7 @@ int diff_opt_parse(struct diff_options *options,
DIFF_OPT_CLR(options, FUNCCONTEXT);
else if ((argcount = parse_long_opt("output", av, &optarg))) {
char *path = prefix_filename(prefix, optarg);
- options->file = fopen(path, "w");
- if (!options->file)
- die_errno("Could not open '%s'", path);
+ options->file = xfopen(path, "w");
options->close_file = 1;
if (options->use_color != GIT_COLOR_ALWAYS)
options->use_color = GIT_COLOR_NEVER;
@@ -4807,9 +4805,7 @@ void diff_flush(struct diff_options *options)
*/
if (options->close_file)
fclose(options->file);
- options->file = fopen("/dev/null", "w");
- if (!options->file)
- die_errno("Could not open /dev/null");
+ options->file = xfopen("/dev/null", "w");
options->close_file = 1;
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];