diff options
author | Larry D'Anna <larry@elder-gods.org> | 2010-02-16 01:55:21 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-02-15 23:04:34 -0800 |
commit | 6977c250ac6cacb5ee441bff832fdeab4d0cd8f9 (patch) | |
tree | 65395c21da0f7326b50da68e05a6d2db78cd182b | |
parent | b599672316ae0e0cf827e5e2cd6d3bb403d7b8cd (diff) | |
download | git-6977c250ac6cacb5ee441bff832fdeab4d0cd8f9.tar.gz git-6977c250ac6cacb5ee441bff832fdeab4d0cd8f9.tar.xz |
git diff --quiet -w: check and report the status
The option -w tells the diff machinery to inspect the contents to set the
exit status, instead of checking the blob object level difference alone.
However, --quiet tells the diff machinery not to look at the contents, which
means DIFF_FROM_CONTENTS has no chance to inspect the change.
Work it around by calling diff_flush_patch() with output sent to /dev/null.
Signed-off-by: Larry D'Anna <larry@elder-gods.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | diff.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -3520,6 +3520,29 @@ void diff_flush(struct diff_options *options) separator++; } + if (output_format & DIFF_FORMAT_NO_OUTPUT && + DIFF_OPT_TST(options, EXIT_WITH_STATUS) && + DIFF_OPT_TST(options, DIFF_FROM_CONTENTS)) { + /* + * run diff_flush_patch for the exit status. setting + * options->file to /dev/null should be safe, becaue we + * aren't supposed to produce any output anyway. + */ + if (options->close_file) + fclose(options->file); + options->file = fopen("/dev/null", "w"); + if (!options->file) + die_errno("Could not open /dev/null"); + options->close_file = 1; + for (i = 0; i < q->nr; i++) { + struct diff_filepair *p = q->queue[i]; + if (check_pair_status(p)) + diff_flush_patch(p, options); + if (options->found_changes) + break; + } + } + if (output_format & DIFF_FORMAT_PATCH) { if (separator) { putc(options->line_termination, options->file); |