X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=.git_template%2Fhooks%2Fpre-commit;h=33a6f8ca3280a918b2e91175818d507771790607;hb=a44ee8f739e11ef40402ea7eab92508f70445e68;hp=182dcb9af9ea5fcac76786e4bf293c677afbd5ed;hpb=eb9b839bb5a91c60cc4f6eb9d7e38ffbf73f0e90;p=distro-setup diff --git a/.git_template/hooks/pre-commit b/.git_template/hooks/pre-commit index 182dcb9..33a6f8c 100755 --- a/.git_template/hooks/pre-commit +++ b/.git_template/hooks/pre-commit @@ -94,8 +94,9 @@ if ! git rev-list HEAD --count &>/dev/null; then cat <<'EOF' Whitespace issues found. We can't fix in a pre-commit hook for the first commit. Either fix on your own. I suggest https://github.com/dlenski/wtf, from git root: -find . -not -name .git -type f -exec bash -c \ - 'grep -Il "" "$1" &>/dev/null && wtf.py -i -E lf "$1"' _ {} \; + +git ls-files --exclude-standard -cmo --no-empty-directory | while read -r f; do if [[ -L $f ]] || ! grep -Iq . "$f"; then continue; fi; wtf.py -i -E lf "$f"; done + or allow whitespace with: git config hooks.allowwhitespace true, or export GIT_ALLOWWHITESPACE=true EOF