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