Merge branch 'ld/maint-diff-quiet-w' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 5 Mar 2010 06:26:39 +0000 (22:26 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 5 Mar 2010 06:26:39 +0000 (22:26 -0800)
* ld/maint-diff-quiet-w:
git-diff: add a test for git diff --quiet -w
git diff --quiet -w: check and report the status

1  2 
diff.c
diff --combined diff.c
index 989dbc54cbb31c095cc45fb5bb74f62077f1c635,7216b1e8db75fb28916be85139b816e9c6be93f8..0d465faa1e546382267dc0779116a013647ecf41
--- 1/diff.c
--- 2/diff.c
+++ b/diff.c
@@@ -2893,8 -2893,6 +2893,8 @@@ int diff_opt_parse(struct diff_options 
                ;
        else if (!prefixcmp(arg, "--output=")) {
                options->file = fopen(arg + strlen("--output="), "w");
 +              if (!options->file)
 +                      die_errno("Could not open '%s'", arg + strlen("--output="));
                options->close_file = 1;
        } else
                return 0;
@@@ -3522,6 -3520,29 +3522,29 @@@ void diff_flush(struct diff_options *op
                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);
@@@ -3644,7 -3665,7 +3667,7 @@@ static void diffcore_skip_stat_unmatch(
                struct diff_filepair *p = q->queue[i];
  
                /*
 -               * 1. Entries that come from stat info dirtyness
 +               * 1. Entries that come from stat info dirtiness
                 *    always have both sides (iow, not create/delete),
                 *    one side of the object name is unknown, with
                 *    the same mode and size.  Keep the ones that