1#!/bin/sh2#3# An example hook script to verify what is about to be committed.4# Called by "git commit" with no arguments. The hook should5# exit with non-zero status after issuing an appropriate message if6# it wants to stop the commit.7#8# To enable this hook, rename this file to "pre-commit".910if git rev-parse --verify HEAD >/dev/null 2>&111then12against=HEAD13else14# Initial commit: diff against an empty tree object15against=4b825dc642cb6eb9a060e54bf8d69288fbee490416fi1718# If you want to allow non-ascii filenames set this variable to true.19allownonascii=$(git config hooks.allownonascii)2021# Cross platform projects tend to avoid non-ascii filenames; prevent22# them from being added to the repository. We exploit the fact that the23# printable range starts at the space character and ends with tilde.24if [ "$allownonascii" != "true" ] &&25# Note that the use of brackets around a tr range is ok here, (it's26# even required, for portability to Solaris 10's /usr/bin/tr), since27# the square bracket bytes happen to fall in the designated range.28test "$(git diff --cached --name-only --diff-filter=A -z $against |29LC_ALL=C tr -d '[ -~]\0')"30then31echo "Error: Attempt to add a non-ascii file name."32echo33echo "This can cause problems if you want to work"34echo "with people on other platforms."35echo36echo "To be portable it is advisable to rename the file ..."37echo38echo "If you know what you are doing you can disable this"39echo "check using:"40echo41echo " git config hooks.allownonascii true"42echo43exit 144fi4546exec git diff-index --check --cached $against --