summaryrefslogtreecommitdiff
path: root/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'hooks')
-rw-r--r--hooks/pre-commit23
1 files changed, 23 insertions, 0 deletions
diff --git a/hooks/pre-commit b/hooks/pre-commit
new file mode 100644
index 000000000..44010fa1a
--- /dev/null
+++ b/hooks/pre-commit
@@ -0,0 +1,23 @@
1#!/bin/sh
2
3#check the config, in case the user really wants to allow tabs...
4allowtabs=$(git config hooks.allowtabs)
5if [ "$allowtabs" != "true" ] &&
6 git diff --cached | egrep '^\+.* '
7then
8 cat<<END;
9Error: This commit would contain a tab, which is against this repo's policy.
10END
11 exit 1
12fi
13
14# If there are whitespace errors, print the offending file names and fail.
15if
16# Use git built-in checks for trailing whitespaces
17 ! git diff --check --cached
18then
19 cat<<END;
20Error: This commit would contain trailing spaces, which is against this repo's policy.
21END
22 exit 1
23fi