summaryrefslogtreecommitdiffstats
path: root/script/git-hooks/check-trailing-whitespace
diff options
context:
space:
mode:
Diffstat (limited to 'script/git-hooks/check-trailing-whitespace')
-rwxr-xr-xscript/git-hooks/check-trailing-whitespace17
1 files changed, 17 insertions, 0 deletions
diff --git a/script/git-hooks/check-trailing-whitespace b/script/git-hooks/check-trailing-whitespace
new file mode 100755
index 0000000..4dc1a6d
--- /dev/null
+++ b/script/git-hooks/check-trailing-whitespace
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+git diff-index --cached --check HEAD -- :/*.[ch] :/*.p[ylm]
+
+if [ $? != 0 ]; then
+ echo
+ echo "The commit failed because it seems to introduce trailing whitespace"
+ echo "into C, Perl, or Python code."
+ echo
+ echo "If you are sure you want to do this, repeat the commit with the "
+ echo "--no-verify, like this:"
+ echo
+ echo " git commit --no-verify"
+ exit 1
+fi
+
+exit 0