annotate vendor/drupal/coder/.git/hooks/pre-commit.sample @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 1fec387a4317
children
rev   line source
Chris@14 1 #!/bin/sh
Chris@14 2 #
Chris@14 3 # An example hook script to verify what is about to be committed.
Chris@14 4 # Called by "git commit" with no arguments. The hook should
Chris@14 5 # exit with non-zero status after issuing an appropriate message if
Chris@14 6 # it wants to stop the commit.
Chris@14 7 #
Chris@14 8 # To enable this hook, rename this file to "pre-commit".
Chris@14 9
Chris@14 10 if git rev-parse --verify HEAD >/dev/null 2>&1
Chris@14 11 then
Chris@14 12 against=HEAD
Chris@14 13 else
Chris@14 14 # Initial commit: diff against an empty tree object
Chris@14 15 against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
Chris@14 16 fi
Chris@14 17
Chris@14 18 # If you want to allow non-ASCII filenames set this variable to true.
Chris@14 19 allownonascii=$(git config --bool hooks.allownonascii)
Chris@14 20
Chris@14 21 # Redirect output to stderr.
Chris@14 22 exec 1>&2
Chris@14 23
Chris@14 24 # Cross platform projects tend to avoid non-ASCII filenames; prevent
Chris@14 25 # them from being added to the repository. We exploit the fact that the
Chris@14 26 # printable range starts at the space character and ends with tilde.
Chris@14 27 if [ "$allownonascii" != "true" ] &&
Chris@14 28 # Note that the use of brackets around a tr range is ok here, (it's
Chris@14 29 # even required, for portability to Solaris 10's /usr/bin/tr), since
Chris@14 30 # the square bracket bytes happen to fall in the designated range.
Chris@14 31 test $(git diff --cached --name-only --diff-filter=A -z $against |
Chris@14 32 LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
Chris@14 33 then
Chris@14 34 cat <<\EOF
Chris@14 35 Error: Attempt to add a non-ASCII file name.
Chris@14 36
Chris@14 37 This can cause problems if you want to work with people on other platforms.
Chris@14 38
Chris@14 39 To be portable it is advisable to rename the file.
Chris@14 40
Chris@14 41 If you know what you are doing you can disable this check using:
Chris@14 42
Chris@14 43 git config hooks.allownonascii true
Chris@14 44 EOF
Chris@14 45 exit 1
Chris@14 46 fi
Chris@14 47
Chris@14 48 # If there are whitespace errors, print the offending file names and fail.
Chris@14 49 exec git diff-index --check --cached $against --