"diff --check" should affect exit status
[gitweb.git] / builtin-diff.c
index 55fb84c730e4141bdb53fec6602a2bdafc99f8fd..9d878f6a71a5a7a53b11112396cb963ba149d6e6 100644 (file)
@@ -247,7 +247,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
        /* If the user asked for our exit code then don't start a
         * pager or we would end up reporting its exit code instead.
         */
-       if (!DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))
+       if (!DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS) &&
+           (!(rev.diffopt.output_format & DIFF_FORMAT_CHECKDIFF)))
                setup_pager();
 
        /* Do we have --cached and not have a pending object, then
@@ -353,7 +354,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
                                             ent, ents);
        if (DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))
                result = DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES) != 0;
-
+       if (rev.diffopt.output_format & DIFF_FORMAT_CHECKDIFF)
+               return DIFF_OPT_TST(&rev.diffopt, CHECK_FAILED) != 0;
        if (1 < rev.diffopt.skip_stat_unmatch)
                refresh_index_quietly();
        return result;