]> git.ipfire.org Git - thirdparty/git.git/blob - .clang-format
Merge branch 'master' of github.com:vnwildman/git
[thirdparty/git.git] / .clang-format
1 # This file is an example configuration for clang-format 5.0.
2 #
3 # Note that this style definition should only be understood as a hint
4 # for writing new code. The rules are still work-in-progress and does
5 # not yet exactly match the style we have in the existing code.
6
7 # Use tabs whenever we need to fill whitespace that spans at least from one tab
8 # stop to the next one.
9 #
10 # These settings are mirrored in .editorconfig. Keep them in sync.
11 UseTab: Always
12 TabWidth: 8
13 IndentWidth: 8
14 ContinuationIndentWidth: 8
15 ColumnLimit: 80
16
17 # C Language specifics
18 Language: Cpp
19
20 # Align parameters on the open bracket
21 # someLongFunction(argument1,
22 # argument2);
23 AlignAfterOpenBracket: Align
24
25 # Don't align consecutive assignments
26 # int aaaa = 12;
27 # int b = 14;
28 AlignConsecutiveAssignments: false
29
30 # Don't align consecutive declarations
31 # int aaaa = 12;
32 # double b = 3.14;
33 AlignConsecutiveDeclarations: false
34
35 # Align escaped newlines as far left as possible
36 # #define A \
37 # int aaaa; \
38 # int b; \
39 # int cccccccc;
40 AlignEscapedNewlines: Left
41
42 # Align operands of binary and ternary expressions
43 # int aaa = bbbbbbbbbbb +
44 # cccccc;
45 AlignOperands: true
46
47 # Don't align trailing comments
48 # int a; // Comment a
49 # int b = 2; // Comment b
50 AlignTrailingComments: false
51
52 # By default don't allow putting parameters onto the next line
53 # myFunction(foo, bar, baz);
54 AllowAllParametersOfDeclarationOnNextLine: false
55
56 # Don't allow short braced statements to be on a single line
57 # if (a) not if (a) return;
58 # return;
59 AllowShortBlocksOnASingleLine: false
60 AllowShortCaseLabelsOnASingleLine: false
61 AllowShortFunctionsOnASingleLine: false
62 AllowShortIfStatementsOnASingleLine: false
63 AllowShortLoopsOnASingleLine: false
64
65 # By default don't add a line break after the return type of top-level functions
66 # int foo();
67 AlwaysBreakAfterReturnType: None
68
69 # Pack as many parameters or arguments onto the same line as possible
70 # int myFunction(int aaaaaaaaaaaa, int bbbbbbbb,
71 # int cccc);
72 BinPackArguments: true
73 BinPackParameters: true
74
75 # Attach braces to surrounding context except break before braces on function
76 # definitions.
77 # void foo()
78 # {
79 # if (true) {
80 # } else {
81 # }
82 # };
83 BreakBeforeBraces: Linux
84
85 # Break after operators
86 # int valuve = aaaaaaaaaaaaa +
87 # bbbbbb -
88 # ccccccccccc;
89 BreakBeforeBinaryOperators: None
90 BreakBeforeTernaryOperators: false
91
92 # Don't break string literals
93 BreakStringLiterals: false
94
95 # Use the same indentation level as for the switch statement.
96 # Switch statement body is always indented one level more than case labels.
97 IndentCaseLabels: false
98
99 # Don't indent a function definition or declaration if it is wrapped after the
100 # type
101 IndentWrappedFunctionNames: false
102
103 # Align pointer to the right
104 # int *a;
105 PointerAlignment: Right
106
107 # Don't insert a space after a cast
108 # x = (int32)y; not x = (int32) y;
109 SpaceAfterCStyleCast: false
110
111 # Insert spaces before and after assignment operators
112 # int a = 5; not int a=5;
113 # a += 42; a+=42;
114 SpaceBeforeAssignmentOperators: true
115
116 # Put a space before opening parentheses only after control statement keywords.
117 # void f() {
118 # if (true) {
119 # f();
120 # }
121 # }
122 SpaceBeforeParens: ControlStatements
123
124 # Don't insert spaces inside empty '()'
125 SpaceInEmptyParentheses: false
126
127 # The number of spaces before trailing line comments (// - comments).
128 # This does not affect trailing block comments (/* - comments).
129 SpacesBeforeTrailingComments: 1
130
131 # Don't insert spaces in casts
132 # x = (int32) y; not x = ( int32 ) y;
133 SpacesInCStyleCastParentheses: false
134
135 # Don't insert spaces inside container literals
136 # var arr = [1, 2, 3]; not var arr = [ 1, 2, 3 ];
137 SpacesInContainerLiterals: false
138
139 # Don't insert spaces after '(' or before ')'
140 # f(arg); not f( arg );
141 SpacesInParentheses: false
142
143 # Don't insert spaces after '[' or before ']'
144 # int a[5]; not int a[ 5 ];
145 SpacesInSquareBrackets: false
146
147 # Insert a space after '{' and before '}' in struct initializers
148 Cpp11BracedListStyle: false
149
150 # A list of macros that should be interpreted as foreach loops instead of as
151 # function calls. Taken from:
152 # git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' \
153 # | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \
154 # | sort | uniq
155 ForEachMacros:
156 - 'for_each_abbrev'
157 - 'for_each_builtin'
158 - 'for_each_string_list_item'
159 - 'for_each_ut'
160 - 'for_each_wanted_builtin'
161 - 'list_for_each'
162 - 'list_for_each_dir'
163 - 'list_for_each_prev'
164 - 'list_for_each_prev_safe'
165 - 'list_for_each_safe'
166
167 # The maximum number of consecutive empty lines to keep.
168 MaxEmptyLinesToKeep: 1
169
170 # No empty line at the start of a block.
171 KeepEmptyLinesAtTheStartOfBlocks: false
172
173 # Penalties
174 # This decides what order things should be done if a line is too long
175 PenaltyBreakAssignment: 10
176 PenaltyBreakBeforeFirstCallParameter: 30
177 PenaltyBreakComment: 10
178 PenaltyBreakFirstLessLess: 0
179 PenaltyBreakString: 10
180 PenaltyExcessCharacter: 100
181 PenaltyReturnTypeOnItsOwnLine: 60
182
183 # Don't sort #include's
184 SortIncludes: false