This is a repost of the topic I posted yesterday, rebased on top of master and omitting the changes already applied to it. Of the series the most interesting is [3/5], where I implement Junio's suggestion of further refactoring to get rid of emit_line_with_ws(). [1/5] "diff --check" should affect exit status [2/5] New version of pre-commit hook [3/5] Unify whitespace checking [4/5] Make "diff --check" output match "git apply" [5/5] Add tests for "git diff --check" with core.whitespace options I think there are still some opportunities for further refactoring and clean-up, but this is a good start. Overall the refactoring saves duplication and reduces the line count (apart from the tests, of course, where line count goes unequivocally up). Documentation/diff-options.txt | 4 +- builtin-apply.c | 56 +++---------- builtin-diff-files.c | 2 + builtin-diff-index.c | 2 + builtin-diff-tree.c | 28 +++--- builtin-diff.c | 3 +- cache.h | 4 + diff.c | 172 +++++++++--------------------------- diff.h | 1 + t/t4015-diff-whitespace.sh | 189 +++++++++++++++++++++++++++++++++++++++- templates/hooks--pre-commit | 67 ++------------- ws.c | 105 ++++++++++++++++++++++ 12 files changed, 379 insertions(+), 254 deletions(-) Cheers, Wincent - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html