clang-format: formalize some of the spacing rules

There are some spacing rules that we follow in the project and it makes sense to formalize them: * Ensure there is no space inserted after the logical not '!' operator. * Ensure there is no space before the case statement's colon. * Ensure there is no space before the first bracket '[' of an array. * Ensure there is no space in empty blocks. Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Karthik Nayak committed Jul 23, 2024 at 10:21 UTC 1993918b9fe13cde1a2eaaba07cb6d0c96134373
1 file changed +15
.clang-format
+15
@@ -118,11 +118,18 @@ PointerAlignment: Right
118 # x = (int32)y; not x = (int32) y;
119 SpaceAfterCStyleCast: false
120
121 +# No space is inserted after the logical not operator
122 +SpaceAfterLogicalNot: false
123 +
124 # Insert spaces before and after assignment operators
125 # int a = 5; not int a=5;
126 # a += 42; a+=42;
127 SpaceBeforeAssignmentOperators: true
128
129 +# Spaces will be removed before case colon.
130 +# case 1: break; not case 1 : break;
131 +SpaceBeforeCaseColon: false
132 +
133 # Put a space before opening parentheses only after control statement keywords.
134 # void f() {
135 # if (true) {
@@ -134,6 +141,14 @@ SpaceBeforeParens: ControlStatements
141 # Don't insert spaces inside empty '()'
142 SpaceInEmptyParentheses: false
143
144 +# No space before first '[' in arrays
145 +# int a[5][5]; not int a [5][5];
146 +SpaceBeforeSquareBrackets: false
147 +
148 +# No space will be inserted into {}
149 +# while (true) {} not while (true) { }
150 +SpaceInEmptyBlock: false
151 +
152 # The number of spaces before trailing line comments (// - comments).
153 # This does not affect trailing block comments (/* - comments).
154 SpacesBeforeTrailingComments: 1