Add clang-format file, tweak style-check.sh
authorBrenden Blanco <bblanco@plumgrid.com>
Tue, 19 Apr 2016 21:14:42 +0000 (14:14 -0700)
committerBrenden Blanco <bblanco@plumgrid.com>
Tue, 19 Apr 2016 21:51:24 +0000 (14:51 -0700)
Add an initial .clang-format file, based on LLVM's style base. Inform
the style-check wrapper to only consider h, c, and cc files when it
runs, and print out the --verbose output upon failure.

.clang-format [new file with mode: 0644]
scripts/style-check.sh

diff --git a/.clang-format b/.clang-format
new file mode 100644 (file)
index 0000000..27ba3b3
--- /dev/null
@@ -0,0 +1,4 @@
+---
+BasedOnStyle: Google
+AllowShortIfStatementsOnASingleLine: false
+IndentCaseLabels: false
index 1e90b16..04aa1b2 100755 (executable)
@@ -14,12 +14,10 @@ if ! hash $CLANG_FORMAT 2> /dev/null; then
   exit 1
 fi
 
-n=$(git clang-format $GITREF --binary $CLANG_FORMAT --style llvm --diff --quiet | wc -l)
+cmd="git clang-format $GITREF --binary $CLANG_FORMAT --diff --extensions h,c,cc"
+
+n=$($cmd --quiet | wc -l)
 if [ $n -gt 0 ]; then
-  echo "git clang-format $GITREF --binary $CLANG_FORMAT --style llvm --diff"
-  echo
-  git clang-format $GITREF --binary $CLANG_FORMAT --style llvm --diff
-  echo
-  echo "clang-format returned non-empty diff, please fixup the style" 1>&2
+  $cmd -v
   exit 1
 fi