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