# limitations under the License.
-# This is the git upstream example hook, but it's actually useful.
+# ian: This section is the git upstream example hook, but it's actually useful.
-#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
exit 1
fi
-set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
-# inspired from:
+# ian: inspired from:
# https://github.com/ntc2/conf/blob/master/dot.gitconfig
+# last checked for any changes there on 7/2016
# duplicated at,
# http://stackoverflow.com/a/15398512/14456
-# last checked for any changes there on 7/2016
+set -eE -o pipefail
+trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
+
if [[ $(git config --bool hooks.allowwhitespace) == true ]] || \
[[ $GIT_ALLOWWHITESPACE == true ]]; then
exit 0
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