3 # Hook used to indent all xcos files before commiting
6 XMLLINT="$(git config hooks.xmllint)"
7 if test ! -x "$XMLLINT"
9 echo "Unable to find xmllint executable on the configuration."
11 echo "Please configure it with :"
12 echo " git config hooks.xmllint C:/path/to/xmllint"
16 INDENT="$(git config hooks.indent)"
17 if test ! -x "$INDENT"
19 echo "Unable to find indent executable on the configuration."
21 echo "Please configure it with :"
22 echo " git config hooks.indent C:/path/to/indent"
26 # indent / format file by type
28 # getting against as the current commit
29 if git rev-parse --verify HEAD >/dev/null 2>&1
33 # Initial commit: diff against an empty tree object
34 local against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
37 # loop on modified files
38 git diff --cached --name-only $against |while read file;
40 local ext=$(expr "$file" : ".*\(\..*\)")
63 # Indent the file with xmllint if this is an xcos file
66 if test ! -x "$XMLLINT"
75 echo "Formatting " $file
76 "$XMLLINT" --format -o "$file" "$file"
79 # Indent the file with `indent' if this is a C/CPP file
82 if test ! -x "$INDENT"
91 echo "Indenting " $file
92 "$INDENT" -npro --braces-after-if-line -i4 -ts4 -sob -ss -ncs -sc --no-space-after-parentheses -cp1 --no-tabs -bap -bad -npcs --dont-break-function-decl-args --dont-break-procedure-type -bli0 -l150 -il0 "$file"