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