Re: [PATCH v3 8/8] ci/style-check: add `RemoveBracesLLVM` to '.clang-format'
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Jul 15, 2024, 19:31 UTC
- Message-ID
- <CAOLa=ZQx4UKMfq7q2GMV6nYQGKeCj0dW_P4kG7yDTcdo--1HHQ@mail.gmail.com>
- In-Reply-To
- <xmqqle224npf.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 17 quoted lines
> Karthik Nayak <karthik.188@gmail.com> writes: > >> Ah right. Let me summarise: >> - Method 1: Inject the extra config to '.clang-format' in the CI's job. >> This is the current method. >> - Method 2: Create '.clang-format-ci' to use in the CI >> - Method 2.a: The new file contains '.clang-format' + CI specific >> rules. >> - Method 2.b: The new file simply contains the new rules and we inject >> the rest in the CI's job. >> >> I'd say methods '1' and '2.b' are similar, since they modify the tree on >> the CI. So no real benefit of one over the other, no? > > Sorry, but I am not sure what you are trying to say, especially with > 2.a and 2.b, your assumption on "the new file". Is it tracked? >
Yes. I was referring to a tracked file.
Show 11 quoted lines
> Try running "git describe --dirty" and see if the command can tell > the difference. If you smudge .clang-format, which is a tracked > file, it will be noticed. > > But you can use a temporary file and use --style=file:/... to point > at it. The temporary file can be an untracked and ignored file, > just like any *.o files we would create during a build. Then "git > describe --dirty" would not complain that you are making the working > tree dirty. > > The temporary file does not even have to be inside our working tree.
I feel stupid now. I completely didn't think of this and this solves everything. Thanks for being explicit here. The temporary file absolutely doesn't have to be in our working tree.
Show 13 quoted lines
> If we know we can write into /tmp/clang-format-rules file, then the
> CI script can do something like
>
> {
> cat .clang-format
> echo echo "RemoveBracesLLVM: true"
> } >/tmp/clang-format-rules
> git clang-format --style=file:/tmp/clang-format-rules \
> --diff --extensions c,h "$baseCommit"
>
> right? Then "git status" would even say "there is no untracked
> cruft" (although I do not know we *need* to keep the working tree
> that clean, without untracked cruft).Yes this is the best solution.