"diff --check" should affect exit status

"git diff" has a --check option that can be used to check for whitespace
problems but it only reported by printing warnings to the
console.

Now when the --check option is used we give a non-zero exit status,
making "git diff --check" nicer to use in scripts and hooks.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Wincent Colaiuta
2007-12-13 21:24:52 +01:00
committed by Junio C Hamano
parent 913b45f51b
commit 62c64895cf
8 changed files with 171 additions and 18 deletions

View File

@ -33,5 +33,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
result = run_diff_files_cmd(&rev, argc, argv);
if (DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))
return 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;
return result;
}