aboutsummaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-03-02 12:44:10 -0800
committerJunio C Hamano <gitster@pobox.com>2010-03-02 12:44:10 -0800
commit36420805a738d1cf17e7faf54556b35344421515 (patch)
treec7a52381fbbd90f8ed2f1f5d23c0b99c6338b7d3 /diff.c
parent68a47414846dc62ccc41e41a2f5ba55f80e226b3 (diff)
parent1caaf225f86b7b1818103e72774e191fb1f3d0bb (diff)
downloadgit-36420805a738d1cf17e7faf54556b35344421515.tar.gz
git-36420805a738d1cf17e7faf54556b35344421515.tar.xz
Merge branch 'ld/maint-diff-quiet-w'
* ld/maint-diff-quiet-w: git-diff: add a test for git diff --quiet -w git diff --quiet -w: check and report the status
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/diff.c b/diff.c
index ed3e7c5aa..dfdfa1a81 100644
--- a/diff.c
+++ b/diff.c
@@ -3531,6 +3531,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);