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