Jim Flynn
/
aws-iot-device-sdk-mbed-c
Changes to enabled on-line compiler
platform/ezconnect/wnc14a2a-driver/.git/hooks/pre-commit.sample@0:082731ede69f, 2018-05-30 (annotated)
- Committer:
- JMF
- Date:
- Wed May 30 20:59:51 2018 +0000
- Revision:
- 0:082731ede69f
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JMF | 0:082731ede69f | 1 | #!/bin/sh |
JMF | 0:082731ede69f | 2 | # |
JMF | 0:082731ede69f | 3 | # An example hook script to verify what is about to be committed. |
JMF | 0:082731ede69f | 4 | # Called by "git commit" with no arguments. The hook should |
JMF | 0:082731ede69f | 5 | # exit with non-zero status after issuing an appropriate message if |
JMF | 0:082731ede69f | 6 | # it wants to stop the commit. |
JMF | 0:082731ede69f | 7 | # |
JMF | 0:082731ede69f | 8 | # To enable this hook, rename this file to "pre-commit". |
JMF | 0:082731ede69f | 9 | |
JMF | 0:082731ede69f | 10 | if git rev-parse --verify HEAD >/dev/null 2>&1 |
JMF | 0:082731ede69f | 11 | then |
JMF | 0:082731ede69f | 12 | against=HEAD |
JMF | 0:082731ede69f | 13 | else |
JMF | 0:082731ede69f | 14 | # Initial commit: diff against an empty tree object |
JMF | 0:082731ede69f | 15 | against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 |
JMF | 0:082731ede69f | 16 | fi |
JMF | 0:082731ede69f | 17 | |
JMF | 0:082731ede69f | 18 | # If you want to allow non-ascii filenames set this variable to true. |
JMF | 0:082731ede69f | 19 | allownonascii=$(git config hooks.allownonascii) |
JMF | 0:082731ede69f | 20 | |
JMF | 0:082731ede69f | 21 | # Redirect output to stderr. |
JMF | 0:082731ede69f | 22 | exec 1>&2 |
JMF | 0:082731ede69f | 23 | |
JMF | 0:082731ede69f | 24 | # Cross platform projects tend to avoid non-ascii filenames; prevent |
JMF | 0:082731ede69f | 25 | # them from being added to the repository. We exploit the fact that the |
JMF | 0:082731ede69f | 26 | # printable range starts at the space character and ends with tilde. |
JMF | 0:082731ede69f | 27 | if [ "$allownonascii" != "true" ] && |
JMF | 0:082731ede69f | 28 | # Note that the use of brackets around a tr range is ok here, (it's |
JMF | 0:082731ede69f | 29 | # even required, for portability to Solaris 10's /usr/bin/tr), since |
JMF | 0:082731ede69f | 30 | # the square bracket bytes happen to fall in the designated range. |
JMF | 0:082731ede69f | 31 | test $(git diff --cached --name-only --diff-filter=A -z $against | |
JMF | 0:082731ede69f | 32 | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 |
JMF | 0:082731ede69f | 33 | then |
JMF | 0:082731ede69f | 34 | echo "Error: Attempt to add a non-ascii file name." |
JMF | 0:082731ede69f | 35 | echo |
JMF | 0:082731ede69f | 36 | echo "This can cause problems if you want to work" |
JMF | 0:082731ede69f | 37 | echo "with people on other platforms." |
JMF | 0:082731ede69f | 38 | echo |
JMF | 0:082731ede69f | 39 | echo "To be portable it is advisable to rename the file ..." |
JMF | 0:082731ede69f | 40 | echo |
JMF | 0:082731ede69f | 41 | echo "If you know what you are doing you can disable this" |
JMF | 0:082731ede69f | 42 | echo "check using:" |
JMF | 0:082731ede69f | 43 | echo |
JMF | 0:082731ede69f | 44 | echo " git config hooks.allownonascii true" |
JMF | 0:082731ede69f | 45 | echo |
JMF | 0:082731ede69f | 46 | exit 1 |
JMF | 0:082731ede69f | 47 | fi |
JMF | 0:082731ede69f | 48 | |
JMF | 0:082731ede69f | 49 | # If there are whitespace errors, print the offending file names and fail. |
JMF | 0:082731ede69f | 50 | exec git diff-index --check --cached $against -- |