-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
84 additions
and
5 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Submodule common
deleted from
742c09
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/bin/sh | ||
# | ||
# Check that the code follows a consistent code style | ||
# | ||
|
||
# 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=`gindent --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 | ||
else | ||
INDENT=indent | ||
fi | ||
else | ||
INDENT=gindent | ||
fi | ||
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 \ | ||
--case-indentation2 \ | ||
--braces-after-struct-decl-line \ | ||
--line-length80 \ | ||
--no-tabs \ | ||
--cuddle-else \ | ||
--dont-line-up-parentheses \ | ||
--continuation-indentation4 \ | ||
--honour-newlines \ | ||
--tab-size8 \ | ||
--indent-level2 \ | ||
--leave-preprocessor-space" | ||
|
||
echo "--Checking style--" | ||
for file in `git diff-index --cached --name-only HEAD --diff-filter=ACMR| grep "\.c$"` ; do | ||
# nf is the temporary checkout. This makes sure we check against the | ||
# 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} \ | ||
$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} \ | ||
$newfile 2>> /dev/null | ||
diff -u -p "${nf}" "${newfile}" | ||
r=$? | ||
rm "${newfile}" | ||
rm "${nf}" | ||
if [ $r != 0 ] ; then | ||
echo "=================================================================================================" | ||
echo " Code style error in: $file " | ||
echo " " | ||
echo " Please fix before committing. Don't forget to run git add before trying to commit again. " | ||
echo " If the whole file is to be committed, this should work (run from the top-level directory): " | ||
echo " " | ||
echo " gst-indent $file; git add $file; git commit" | ||
echo " " | ||
echo "=================================================================================================" | ||
exit 1 | ||
fi | ||
done | ||
echo "--Checking style pass--" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters