2013-02-15 00:19:16 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2013-11-23 06:42:13 +08:00
|
|
|
CLANG_FORMAT=${CLANG_FORMAT}
|
|
|
|
|
|
|
|
if [ "${CLANG_FORMAT}x" = "x" ]; then
|
|
|
|
CLANG_FORMAT=`which clang-format`
|
|
|
|
if [ "${CLANG_FORMAT}x" = "x" ]; then
|
|
|
|
echo "Error: cannot find clang-format in your path"
|
2013-11-29 07:35:08 +08:00
|
|
|
exit 1
|
2013-11-23 06:42:13 +08:00
|
|
|
fi
|
2013-02-16 05:26:50 +08:00
|
|
|
fi
|
|
|
|
|
2013-02-15 00:19:16 +08:00
|
|
|
OK=0
|
|
|
|
|
|
|
|
for ARG in "$@"
|
|
|
|
do
|
2014-08-18 08:40:13 +08:00
|
|
|
${CLANG_FORMAT} -style=llvm $ARG | diff -u $ARG - >&2
|
2013-02-15 00:19:16 +08:00
|
|
|
|
|
|
|
if [[ $? -eq 1 ]]; then
|
|
|
|
OK=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ $OK -eq "1" ]]; then
|
|
|
|
echo "Error: clang-format reported formatting differences"
|
2013-11-29 07:35:08 +08:00
|
|
|
exit 1
|
2013-02-15 00:19:16 +08:00
|
|
|
else
|
|
|
|
echo "OK: clang-format reported no formatting differences"
|
2013-02-16 05:26:50 +08:00
|
|
|
exit 0
|
2013-02-15 00:19:16 +08:00
|
|
|
fi
|
|
|
|
|