Merge https://github.com/j6t/gitk
[git/gitster.git] / ci / run-style-check.sh
blob6cd4b1d934a76a4e316887d026ef00733bbdf424
1 #!/bin/sh
3 # Perform style check
6 baseCommit=$1
8 # Remove optional braces of control statements (if, else, for, and while)
9 # according to the LLVM coding style. This avoids braces on simple
10 # single-statement bodies of statements but keeps braces if one side of
11 # if/else if/.../else cascade has multi-statement body.
13 # As this rule comes with a warning [1], we want to experiment with it
14 # before adding it in-tree. since the CI job for the style check is allowed
15 # to fail, appending the rule here allows us to validate its efficacy.
16 # While also ensuring that end-users are not affected directly.
18 # [1]: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#removebracesllvm
20 cat .clang-format
21 echo "RemoveBracesLLVM: true"
22 } >/tmp/clang-format-rules
24 git clang-format --style=file:/tmp/clang-format-rules \
25 --diff --extensions c,h "$baseCommit"