util/lint: Fix clang-format test and enable it by default

git diff needed to emit diffs without prefix (e.g. a/ and b/) for
clang-format-diff to be able to work.

Also require that the test succeeds, but note that it only runs on
trees whitelisted in $(top)/.clang-format-scope.

Change-Id: I7e9a32eb9281b5cb0b45506a206500fd1d315372
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/31654
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
Patrick Georgi 2019-02-27 22:02:04 +01:00
parent 626ba097a2
commit 2785290989
1 changed files with 5 additions and 1 deletions

View File

@ -30,5 +30,9 @@ if [ -z "$files_to_check" ]; then
fi
if [ $(clang-format $files_to_check | wc -l) -gt 0 ]; then
git diff HEAD~..HEAD -- $files_to_check | clang-format-diff
if [ "$(git diff --no-prefix HEAD~..HEAD -- $files_to_check | clang-format-diff)" != "" ]; then
echo "Coding style mismatch. The following patch fixes it:"
git diff --no-prefix HEAD~..HEAD -- $files_to_check | clang-format-diff
exit 1
fi
fi