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