summaryrefslogtreecommitdiffstats
path: root/git_hooks/pre-commit
diff options
context:
space:
mode:
Diffstat (limited to 'git_hooks/pre-commit')
-rwxr-xr-xgit_hooks/pre-commit13
1 files changed, 11 insertions, 2 deletions
diff --git a/git_hooks/pre-commit b/git_hooks/pre-commit
index 6ffc063..3de975b 100755
--- a/git_hooks/pre-commit
+++ b/git_hooks/pre-commit
@@ -19,7 +19,10 @@ fi
19# 19#
20# Configuration check 20# Configuration check
21# 21#
22XMLINDENT="$(git config --get hooks.xmlindent)" 22if test ! -x "$XMLINDENT"
23then
24 XMLINDENT="$(git config --get hooks.xmlindent)"
25fi
23if test ! -x "$XMLINDENT" 26if test ! -x "$XMLINDENT"
24then 27then
25 echo "Unable to find xmlindent executable on the configuration." 28 echo "Unable to find xmlindent executable on the configuration."
@@ -45,7 +48,10 @@ else
45 XMLINDENT_IGNORED="$(find $(git config --get-all xmlindent.ignored))" 48 XMLINDENT_IGNORED="$(find $(git config --get-all xmlindent.ignored))"
46fi 49fi
47 50
48ASTYLE="$(git config --get hooks.astyle)" 51if test ! -x "$ASTYLE"
52then
53 ASTYLE="$(git config --get hooks.astyle)"
54fi
49if test ! -x "$ASTYLE" 55if test ! -x "$ASTYLE"
50then 56then
51 echo "Unable to find astyle executable on the configuration." 57 echo "Unable to find astyle executable on the configuration."
@@ -128,6 +134,9 @@ __indent_xml() {
128 134
129 echo "Formatting" "$FILES" 135 echo "Formatting" "$FILES"
130 "$XMLINDENT" -w -i 4 $FILES || return 2; 136 "$XMLINDENT" -w -i 4 $FILES || return 2;
137 # xmlindent does not remove trailing whitespaces
138 # and might add some on empty lines
139 sed -i -e 's/[ \t]*$//' $FILES || return 2;
131 git add $FILES || return 3; 140 git add $FILES || return 3;
132} 141}
133 142