aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin C Meyer <ben@meyerhome.net>2010-03-16 23:45:07 -0400
committerBenjamin C Meyer <ben@meyerhome.net>2010-03-17 01:56:22 -0400
commit78088e500b3677f4faf6e944f902c683d47b721b (patch)
treea691e31ddcce3e7d115aa7739cdb964a29f6cf11
parent25725bc30bbf24919e82a9e2ecbe055ba1ab3061 (diff)
downloadgit-hooks-78088e500b3677f4faf6e944f902c683d47b721b.tar.gz
git-hooks-78088e500b3677f4faf6e944f902c683d47b721b.tar.bz2
Add a pre-commit hook that checks for whitespace errors
Signed-off-by: Benjamin C Meyer <ben@meyerhome.net>
-rwxr-xr-xcontrib/pre-commit/whitespace20
1 files changed, 20 insertions, 0 deletions
diff --git a/contrib/pre-commit/whitespace b/contrib/pre-commit/whitespace
new file mode 100755
index 0000000..ee588cc
--- /dev/null
+++ b/contrib/pre-commit/whitespace
@@ -0,0 +1,20 @@
+#!/bin/bash -e
+
+function run_test {
+ if git rev-parse --verify HEAD >/dev/null 2>&1 ; then
+ head="HEAD"
+ else
+ # First commit, use an empty tree
+ head="4b825dc642cb6eb9a060e54bf8d69288fbee4904"
+ fi
+ git diff-index --check --cached "${head}" --
+}
+
+case "${1}" in
+ --about )
+ echo "Check for introduced trailing whitespace or an indent that uses a space before a tab."
+ ;;
+ * )
+ run_test
+ ;;
+esac