@matheusbsbs / matheus-bagliano / commits / 6977c250ac
Fork 0

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>

Larry D'Anna committed Feb 16, 2010 at 01:55 UTC 6977c250ac6cacb5ee441bff832fdeab4d0cd8f9
1 file changed +23
diff.c
+23
@@ -3520,6 +3520,29 @@ void diff_flush(struct diff_options *options)
3520 separator++;
3521 }
3522
3523 + if (output_format & DIFF_FORMAT_NO_OUTPUT &&
3524 + DIFF_OPT_TST(options, EXIT_WITH_STATUS) &&
3525 + DIFF_OPT_TST(options, DIFF_FROM_CONTENTS)) {
3526 + /*
3527 + * run diff_flush_patch for the exit status. setting
3528 + * options->file to /dev/null should be safe, becaue we
3529 + * aren't supposed to produce any output anyway.
3530 + */
3531 + if (options->close_file)
3532 + fclose(options->file);
3533 + options->file = fopen("/dev/null", "w");
3534 + if (!options->file)
3535 + die_errno("Could not open /dev/null");
3536 + options->close_file = 1;
3537 + for (i = 0; i < q->nr; i++) {
3538 + struct diff_filepair *p = q->queue[i];
3539 + if (check_pair_status(p))
3540 + diff_flush_patch(p, options);
3541 + if (options->found_changes)
3542 + break;
3543 + }
3544 + }
3545 +
3546 if (output_format & DIFF_FORMAT_PATCH) {
3547 if (separator) {
3548 putc(options->line_termination, options->file);