#!/bin/sh set -ev rm -rf $0.dir mkdir $0.dir cd $0.dir cat > my-commit-hook <&2 if test $(git diff --cached --name-only --diff-filter=A -z HEAD | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 then echo "Error: Attempt to add a non-ascii file name." exit 1 fi # If there are whitespace errors, print the offending file names and fail. echo git diff-index --check --cached HEAD -- exec git diff-index --check --cached HEAD -- EOF cat > git-hook.fac <> my-commit-hook git commit -am 'add nice hooks' cat > newfile <