From: Benjamin C Meyer Date: Wed, 17 Mar 2010 03:45:07 +0000 (-0400) Subject: Add a pre-commit hook that checks for whitespace errors X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=78088e500b3677f4faf6e944f902c683d47b721b;p=git-hooks.git Add a pre-commit hook that checks for whitespace errors Signed-off-by: Benjamin C Meyer --- 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