diff options
author | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2009-03-10 19:47:34 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2009-03-10 19:47:34 +0000 |
commit | 2ce1a3c29d47068e1e74722ab083fa7d5dcf51a0 (patch) | |
tree | a08cbfc4bcef26d54e21c95ed109cff34a591c23 /hooks | |
parent | f8b3d9167a75c5acb514d43173d8d29d413a6e9c (diff) |
pre-commit.hook: check for GNU indent before using it, and allow gnuindent as binary name
Diffstat (limited to 'hooks')
-rwxr-xr-x | hooks/pre-commit.hook | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/hooks/pre-commit.hook b/hooks/pre-commit.hook index e538fbd..9b66554 100755 --- a/hooks/pre-commit.hook +++ b/hooks/pre-commit.hook @@ -2,8 +2,34 @@ # # Check that the code follows a consistant code style # - -# FIXME : Add a check for existence of indent, and return 0 if not present + +# Check for existence of indent, and error out if not present. +# On some *bsd systems the binary seems to be called gnunindent, +# so check for that first. + +version=`gnuindent --version 2>/dev/null` +if test x$version = x; then + version=`indent --version 2>/dev/null` + if test x$version = x; then + echo "GStreamer git pre-commit hook:" + echo "Did not find GNU indent, please install it before continuing." + exit 1 + fi + INDENT=indent +else + INDENT=gnuindent +fi + +case `$INDENT --version` in + GNU*) + ;; + default) + echo "GStreamer git pre-commit hook:" + echo "Did not find GNU indent, please install it before continuing." + echo "(Found $INDENT, but it doesn't seem to be GNU indent)" + exit 1 + ;; +esac INDENT_PARAMETERS="--braces-on-if-line \ --case-brace-indentation0 \ @@ -24,11 +50,11 @@ for file in `git-diff-index --cached --name-only HEAD --diff-filter=ACMR| grep " # revision in the index (and not the checked out version). nf=`git checkout-index --temp ${file} | cut -f 1` newfile=`mktemp /tmp/${nf}.XXXXXX` || exit 1 - indent ${INDENT_PARAMETERS} \ + $INDENT ${INDENT_PARAMETERS} \ $nf -o $newfile 2>> /dev/null # FIXME: Call indent twice as it tends to do line-breaks # different for every second call. - indent ${INDENT_PARAMETERS} \ + $INDENT ${INDENT_PARAMETERS} \ $newfile 2>> /dev/null diff -u -p "${nf}" "${newfile}" r=$? |