]> git.ipfire.org Git - thirdparty/git.git/blame - .clang-format
Merge branch 'rs/t6300-compressed-size-fix'
[thirdparty/git.git] / .clang-format
CommitLineData
1bf0259a
SB
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.
6134de6a
BW
6
7# Use tabs whenever we need to fill whitespace that spans at least from one tab
8# stop to the next one.
b548d698 9#
10# These settings are mirrored in .editorconfig. Keep them in sync.
6134de6a
BW
11UseTab: Always
12TabWidth: 8
13IndentWidth: 8
14ContinuationIndentWidth: 8
15ColumnLimit: 80
16
17# C Language specifics
18Language: Cpp
19
20# Align parameters on the open bracket
21# someLongFunction(argument1,
22# argument2);
23AlignAfterOpenBracket: Align
24
25# Don't align consecutive assignments
26# int aaaa = 12;
27# int b = 14;
28AlignConsecutiveAssignments: false
29
30# Don't align consecutive declarations
31# int aaaa = 12;
32# double b = 3.14;
33AlignConsecutiveDeclarations: false
34
35# Align escaped newlines as far left as possible
36# #define A \
37# int aaaa; \
38# int b; \
39# int cccccccc;
40AlignEscapedNewlines: Left
41
42# Align operands of binary and ternary expressions
43# int aaa = bbbbbbbbbbb +
44# cccccc;
45AlignOperands: true
46
47# Don't align trailing comments
48# int a; // Comment a
49# int b = 2; // Comment b
50AlignTrailingComments: false
51
52# By default don't allow putting parameters onto the next line
53# myFunction(foo, bar, baz);
54AllowAllParametersOfDeclarationOnNextLine: false
55
56# Don't allow short braced statements to be on a single line
57# if (a) not if (a) return;
58# return;
59AllowShortBlocksOnASingleLine: false
60AllowShortCaseLabelsOnASingleLine: false
61AllowShortFunctionsOnASingleLine: false
62AllowShortIfStatementsOnASingleLine: false
63AllowShortLoopsOnASingleLine: false
64
65# By default don't add a line break after the return type of top-level functions
66# int foo();
67AlwaysBreakAfterReturnType: 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);
72BinPackArguments: true
73BinPackParameters: 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# };
83BreakBeforeBraces: Linux
84
85# Break after operators
8f815325
AN
86# int value = aaaaaaaaaaaaa +
87# bbbbbb -
88# ccccccccccc;
6134de6a
BW
89BreakBeforeBinaryOperators: None
90BreakBeforeTernaryOperators: false
91
92# Don't break string literals
93BreakStringLiterals: 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.
97IndentCaseLabels: false
98
99# Don't indent a function definition or declaration if it is wrapped after the
100# type
101IndentWrappedFunctionNames: false
102
103# Align pointer to the right
104# int *a;
105PointerAlignment: Right
106
107# Don't insert a space after a cast
108# x = (int32)y; not x = (int32) y;
109SpaceAfterCStyleCast: false
110
111# Insert spaces before and after assignment operators
112# int a = 5; not int a=5;
113# a += 42; a+=42;
114SpaceBeforeAssignmentOperators: true
115
116# Put a space before opening parentheses only after control statement keywords.
117# void f() {
118# if (true) {
119# f();
120# }
121# }
122SpaceBeforeParens: ControlStatements
123
124# Don't insert spaces inside empty '()'
125SpaceInEmptyParentheses: false
126
127# The number of spaces before trailing line comments (// - comments).
128# This does not affect trailing block comments (/* - comments).
129SpacesBeforeTrailingComments: 1
130
131# Don't insert spaces in casts
132# x = (int32) y; not x = ( int32 ) y;
133SpacesInCStyleCastParentheses: false
134
135# Don't insert spaces inside container literals
136# var arr = [1, 2, 3]; not var arr = [ 1, 2, 3 ];
137SpacesInContainerLiterals: false
138
139# Don't insert spaces after '(' or before ')'
140# f(arg); not f( arg );
141SpacesInParentheses: false
142
143# Don't insert spaces after '[' or before ']'
144# int a[5]; not int a[ 5 ];
145SpacesInSquareBrackets: false
146
147# Insert a space after '{' and before '}' in struct initializers
148Cpp11BracedListStyle: false
149
150# A list of macros that should be interpreted as foreach loops instead of as
fc7e03aa
MO
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
155ForEachMacros:
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'
6134de6a
BW
166
167# The maximum number of consecutive empty lines to keep.
168MaxEmptyLinesToKeep: 1
169
170# No empty line at the start of a block.
171KeepEmptyLinesAtTheStartOfBlocks: false
172
173# Penalties
174# This decides what order things should be done if a line is too long
42efde4c
JS
175PenaltyBreakAssignment: 10
176PenaltyBreakBeforeFirstCallParameter: 30
177PenaltyBreakComment: 10
6134de6a 178PenaltyBreakFirstLessLess: 0
42efde4c
JS
179PenaltyBreakString: 10
180PenaltyExcessCharacter: 100
a3715d43 181PenaltyReturnTypeOnItsOwnLine: 60
6134de6a
BW
182
183# Don't sort #include's
184SortIncludes: false