Skip to content

Commit bfbac98

Browse files
KarthikNayakgitster
authored andcommitted
clang-format: add 'RemoveBracesLLVM' to the main config
In 1b8f306 (ci/style-check: add `RemoveBracesLLVM` in CI job, 2024-07-23) we added 'RemoveBracesLLVM' to the CI job of running the clang formatter. This rule checks and warns against using braces on simple single-statement bodies of statements. Since we haven't had any issues regarding this rule, we can now move it into the main clang-format config and remove it from being CI exclusive. Signed-off-by: Karthik Nayak <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8777874 commit bfbac98

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

.clang-format

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,9 @@ KeepEmptyLinesAtTheStartOfBlocks: false
220220

221221
# Don't sort #include's
222222
SortIncludes: false
223+
224+
# Remove optional braces of control statements (if, else, for, and while)
225+
# according to the LLVM coding style. This avoids braces on simple
226+
# single-statement bodies of statements but keeps braces if one side of
227+
# if/else if/.../else cascade has multi-statement body.
228+
RemoveBracesLLVM: true

ci/run-style-check.sh

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,5 @@
55

66
baseCommit=$1
77

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.
12-
#
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.
17-
#
18-
# [1]: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#removebracesllvm
19-
{
20-
cat .clang-format
21-
echo "RemoveBracesLLVM: true"
22-
} >/tmp/clang-format-rules
23-
24-
git clang-format --style=file:/tmp/clang-format-rules \
8+
git clang-format --style=file:.clang-format \
259
--diff --extensions c,h "$baseCommit"

0 commit comments

Comments
 (0)