clang-format: set 'ColumnLimit' to 0

When clang-format was introduced to the Git project in 6134de6ac1 (clang-format: outline the git project's coding style, 2017-08-14), the 'ColumnLimit' was set to 80. This is inline with our recommendation in 'Documentation/CodingGuidelines', which states: We try to keep to at most 80 characters per line. However while this is recommended limit, this is not the enforced limit. In some cases in we do overflow this limit to prioritize readability. Setting the 'ColumnLimit' also means that shorter lines are concatenated to simply as the result would still be below 80 characters, which is undesirable. In the past, we tried to adjust the penalties around line wrapping, once in 42efde4c29 (clang-format: adjust line break penalties, 2017-09-29) and another time in 5e9fa0f9fa (clang-format: re-adjust line break penalties, 2024-10-18). While these settings help tweak the line break penalties to be more in-line with the requirements of the Git project, using 'clang-format' still produces a lot of false positives. So to make 'clang-format' more usable, set the 'ColumnLimit' to 0. This means that line-wrapping is no-longer a concern of the formatter and something that the user needs to take care of. The previous commit also added a more flexible guideline to the '.editorconfig' setting a 'max_line_length' of 120 characters. This should provide some guidance to users. In the future, it would be nice to re-instate this limit with adequate penalties which would follow our guidelines, but currently, it makes more sense to have a working formatter which we can rely on and which doesn't create too many false positives. Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Karthik Nayak committed Jul 2, 2025 at 11:23 UTC 9e45fc6ce54171bec645917c05b79e3455266a61
1 file changed +9 -12
.clang-format
+9 -12
@@ -12,7 +12,15 @@ UseTab: Always
12 TabWidth: 8
13 IndentWidth: 8
14 ContinuationIndentWidth: 8
15 -ColumnLimit: 80
15 +
16 +# While we do want to enforce a character limit of 80 characters, we often
17 +# allow lines to overflow that limit to prioritize readability. Setting a
18 +# character limit here with penalties has been finicky and creates too many
19 +# false positives.
20 +#
21 +# NEEDSWORK: It would be nice if we can find optimal settings to ensure we
22 +# can re-enable the limit here.
23 +ColumnLimit: 0
24
25 # C Language specifics
26 Language: Cpp
@@ -210,16 +218,5 @@ MaxEmptyLinesToKeep: 1
218 # No empty line at the start of a block.
219 KeepEmptyLinesAtTheStartOfBlocks: false
220
213 -# Penalties
214 -# This decides what order things should be done if a line is too long
215 -PenaltyBreakAssignment: 5
216 -PenaltyBreakBeforeFirstCallParameter: 5
217 -PenaltyBreakComment: 5
218 -PenaltyBreakFirstLessLess: 0
219 -PenaltyBreakOpenParenthesis: 300
220 -PenaltyBreakString: 5
221 -PenaltyExcessCharacter: 10
222 -PenaltyReturnTypeOnItsOwnLine: 300
223 -
221 # Don't sort #include's
222 SortIncludes: false