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".910# If you want to allow non-ascii filenames set this variable to true.11allownonascii=$(git config hooks.allownonascii)1213# Cross platform projects tend to avoid non-ascii filenames; prevent14# them from being added to the repository. We exploit the fact that the15# printable range starts at the space character and ends with tilde.16if [ "$allownonascii" != "true" ] &&17test "$(git diff --cached --name-only --diff-filter=A -z |18LC_ALL=C tr -d '[ -~]\0')"19then20echo "Error: Attempt to add a non-ascii filename."21echo22echo "This can cause problems if you want to work together"23echo "with people on other platforms than you."24echo25echo "To be portable it is adviseable to rename the file ..."26echo27echo "If you know what you are doing you can disable this"28echo "check using:"29echo30echo " git config hooks.allownonascii true"31echo32exit 133fi3435if git-rev-parse --verify HEAD >/dev/null 2>&136then37against=HEAD38else39# Initial commit: diff against an empty tree object40against=4b825dc642cb6eb9a060e54bf8d69288fbee490441fi4243exec git diff-index --check --cached $against --