diff options
| -rw-r--r-- | .gitconfig | 2 | ||||
| -rw-r--r-- | hooks/pre-commit | 33 |
2 files changed, 17 insertions, 18 deletions
diff --git a/.gitconfig b/.gitconfig deleted file mode 100644 index 4cab7f2d9..000000000 --- a/.gitconfig +++ /dev/null | |||
| @@ -1,2 +0,0 @@ | |||
| 1 | [core] | ||
| 2 | whitespace = blank-at-eol,trailing-space,tab-in-indent | ||
diff --git a/hooks/pre-commit b/hooks/pre-commit index 44010fa1a..bad84b14b 100644 --- a/hooks/pre-commit +++ b/hooks/pre-commit | |||
| @@ -1,23 +1,24 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | #check the config, in case the user really wants to allow tabs... | 3 | # Enforce citra's whitespace policy |
| 4 | allowtabs=$(git config hooks.allowtabs) | 4 | git config --local core.whitespace tab-in-indent,trailing-space |
| 5 | if [ "$allowtabs" != "true" ] && | 5 | |
| 6 | git diff --cached | egrep '^\+.* ' | 6 | # If there are whitespace errors, print the offending file names and fail. |
| 7 | then | 7 | if ! git diff --cached --check; then |
| 8 | cat<<END; | 8 | cat<<END; |
| 9 | Error: This commit would contain a tab, which is against this repo's policy. | 9 | |
| 10 | Error: This commit would contain trailing spaces or tabs, which is against this repo's policy. | ||
| 11 | Please correct those issues before commiting. (Use 'git diff --check' for more details) | ||
| 12 | If you know what you are doing, you can try 'git commit --no-verify' to bypass the check | ||
| 10 | END | 13 | END |
| 11 | exit 1 | 14 | exit 1 |
| 12 | fi | 15 | fi |
| 13 | 16 | ||
| 14 | # If there are whitespace errors, print the offending file names and fail. | 17 | # Check for tabs, since tab-in-indent catches only those at the beginning of a line |
| 15 | if | 18 | if git diff --cached | egrep '^\+.* '; then |
| 16 | # Use git built-in checks for trailing whitespaces | 19 | cat<<END; |
| 17 | ! git diff --check --cached | 20 | Error: This commit would contain a tab, which is against this repo's policy. |
| 18 | then | 21 | If you know what you are doing, you can try 'git commit --no-verify' to bypass the check. |
| 19 | cat<<END; | ||
| 20 | Error: This commit would contain trailing spaces, which is against this repo's policy. | ||
| 21 | END | 22 | END |
| 22 | exit 1 | 23 | exit 1 |
| 23 | fi | 24 | fi |