From d8899526551cbfe112e0ecc8280003a8349fc531 Mon Sep 17 00:00:00 2001 From: Nikolai Kondrashov Date: Oct 07 2015 04:52:18 +0000 Subject: TESTS: Make whitespace_test pass without whitespace Make whitespace_test pass if no trailing whitespace was detected at all. Add two comments explaining how searching and failure handling works. Fixes: https://fedorahosted.org/sssd/ticket/2816 Reviewed-by: Lukáš Slebodník --- diff --git a/src/tests/whitespace_test b/src/tests/whitespace_test index ea2aecf..e972b30 100755 --- a/src/tests/whitespace_test +++ b/src/tests/whitespace_test @@ -14,7 +14,12 @@ if [ ! -d "$GIT_DIR" ]; then exit 77 fi -git grep -n -I '\s\+$' -- "$(git rev-parse --show-toplevel)" | +{ + # Look for lines with trailing whitespace in all files tracked by Git + git grep -n -I '\s\+$' -- "$(git rev-parse --show-toplevel)" || + # Don't fail if no such lines were found anywhere + [[ $? == 1 ]] +} | awk -- " BEGIN { found = 0