Subject: Re: [PATCH v2 5/8] clang-format: avoid braces on simple single-statement bodies

From: Junio C Hamano <[email-masked]>
Date: Fri, 12 Jul 2024 08:09:55 -0700

Karthik Nayak <[email-masked]> writes:

> Junio C Hamano <[email-masked]> writes:
>
>> Karthik Nayak <[email-masked]> writes:
>>
>>>     Setting this option to true could lead to incorrect code formatting
>>>     due to clang-format’s lack of complete semantic information. As
>>>     such, extra care should be taken to review code changes made by
>>>     this option.
>>>
>>> The latter seems to be of concern. But since we only use clang-format to
>>> verify the format and not to apply formatting, we should be okay here.
>>
>> Hmph.  Could you tell me where I can read more about "we tell
>> clang-format only to verify but not to apply"?  If that is truely
>> the case, perhaps I shouldn't be worried to much, but it is not
>> clear to me how we enforce that this is to be used only for
>> verification with non-zero false positive, and never for
>> reformatting before submission.
>>
>
> I was referring to the fact that, we expose '.clang-format' via 'make
> style' which only prints the diff to the STDOUT. The user has to still
> manually make these changes.
>
> However users could be using tools to auto-format on save and this could
> be an issue.

Yes.

Of course if we really wanted to avoid end-user confusion and still
want to have this in CI (if only to see how well the rule fares, and
what the actual false-positive rate is), we _could_ run CI's job
with custom .clang-format file that is not visible to end-users in
their normal checkout, or something silly like that.  If we are
going to use it, then we should use it everywhere, making sure
everybody is careful.  If the cost of forcing everybody to be
careful is too high, we may want to retract it, but we won't know
until we try.

Thanks.