summaryrefslogtreecommitdiff
path: root/hooks
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2009-01-22 11:34:17 +0100
committerSebastian Dröge <slomo@circular-chaos.org>2009-01-22 11:34:17 +0100
commitb6a6538e624a4d09e9a35f35dc5988466a1f4737 (patch)
tree86c7aa205c069f213013439c2391b32c204f46e3 /hooks
parent42581d4ebf41013f91b57a30d8f3cbf7e56e478c (diff)
Call indent twice to get correct output
indent tends to add line-breaks at different positions for every second call.
Diffstat (limited to 'hooks')
-rw-r--r--hooks/pre-commit.hook23
1 files changed, 14 insertions, 9 deletions
diff --git a/hooks/pre-commit.hook b/hooks/pre-commit.hook
index 0024483..1bcb90c 100644
--- a/hooks/pre-commit.hook
+++ b/hooks/pre-commit.hook
@@ -4,14 +4,8 @@
#
# FIXME : Add a check for existence of indent, and return 0 if not present
-
-echo "--Checking style--"
-for file in `git-diff-index --name-only HEAD | grep "\.c$"` ; do
- test -f ${file} || continue
- tempfoo=`basename $0`
- newfile=`mktemp /tmp/${tempfoo}.XXXXXX` || exit 1
- indent \
- --braces-on-if-line \
+
+INDENT_PARAMETERS="--braces-on-if-line \
--case-brace-indentation0 \
--case-indentation2 \
--braces-after-struct-decl-line \
@@ -22,8 +16,19 @@ for file in `git-diff-index --name-only HEAD | grep "\.c$"` ; do
--continuation-indentation4 \
--honour-newlines \
--tab-size8 \
- --indent-level2 \
+ --indent-level2"
+
+echo "--Checking style--"
+for file in `git-diff-index --name-only HEAD | grep "\.c$"` ; do
+ test -f ${file} || continue
+ tempfoo=`basename $0`
+ newfile=`mktemp /tmp/${tempfoo}.XXXXXX` || exit 1
+ indent ${INDENT_PARAMETERS} \
$file -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 "${file}" "${newfile}"
r=$?
rm "${newfile}"