diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2017-05-03 12:16:46 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-05-26 05:33:55 +0200 |
commit | 23a9e0712d76a63c5af1caeb816943f466f0300e (patch) | |
tree | 1b065a078058d664ed353f6da0c77842381a5645 /diff.c | |
parent | git_fopen: fix a sparse 'not declared' warning (diff) | |
download | git-23a9e0712d76a63c5af1caeb816943f466f0300e.tar.xz git-23a9e0712d76a63c5af1caeb816943f466f0300e.zip |
use xfopen() in more places
xfopen()
- provides error details
- explains error on reading, or writing, or whatever operation
- has l10n support
- prints file name in the error
Some of these are missing in the places that are replaced with xfopen(),
which is a clear win. In some other places, it's just less code (not as
clearly a win as the previous case but still is).
The only slight regresssion is in remote-testsvn, where we don't report
the file class (marks files) in the error messages anymore. But since
this is a _test_ svn remote transport, I'm not too concerned.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r-- | diff.c | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -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]; |