Created
June 11, 2014 09:02
-
-
Save tombentley/c0eb2768e1718eefd195 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you want to allow filename that differ only by case set this variable to true. | |
allowcasecollision=$(git config hooks.allowcasecollision) | |
if [ "$allowcasecollision" != "true" ] && | |
test "$(git diff --cached --name-only | | |
LC_ALL=C tr [A-Z] [a-z] | | |
sort | | |
uniq --repeated )" | |
then | |
echo "Error: Attempt to add a file name which differs only by case from " | |
echo "another tracked file" | |
echo | |
echo "This can cause problems if you want to work" | |
echo "with people on other platforms." | |
echo | |
echo "To be portable it is advisable to rename the file ..." | |
echo | |
echo "If you know what you are doing you can disable this" | |
echo "check using:" | |
echo | |
echo " git config hooks.allowcasecollision true" | |
echo | |
exit 1 | |
fi |
You could print to stderr instead, like this:
cat >&2 << EOF
Error: Attempt to add a file name which differs only by case from
another tracked file
This can cause problems if you want to work
with people on other platforms.
To be portable it is advisable to rename the file ...
If you know what you are doing you can disable this
check using:
git config hooks.allowcasecollision true
EOF
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a fragment of shell script for a git
pre-commit
hook to prevent adding files which differ only by case. To use it:exec
line (after the similar check for ASCII-only filenames).