Re: [PATCH v3 8/8] ci/style-check: add `RemoveBracesLLVM` to '.clang-format'
- From
Ramsay Jones <ramsay@ramsayjones.plus.com>
- Date
- Jul 13, 2024, 23:18 UTC
- Message-ID
- <cccf899d-12c4-4046-a958-33374bb870c6@ramsayjones.plus.com>
- In-Reply-To
- <CAOLa=ZTkYs_Wz2YM82Nm0yPJX8-hYV3WC-aMEqYNRoS+2ZpG3A@mail.gmail.com>
On 13/07/2024 17:46, Karthik Nayak wrote:
> Junio C Hamano <gitster@pobox.com> writes:
[snip]
Show 10 quoted lines
>> I unfortunately couldn't find an option to "git clang-format" to >> tell it to read from an extra file in addition to the usual >> ".clang-format" file---if such an option existed, we obviously could >> use an untracked/ignored file to prepare the custom format file and >> use it without making the working tree dirty. >> > > This was also something I looked for, but couldn't find. I should have > added that to the commit message. Will do so in the reroll. >
I had a need recently to try applying the git '.clang-format' file to a different project: $ pwd /home/ramsay/sparse $ clang-format --style=file:/home/ramsay/git/.clang-format sparse.c >xxx.c $ meld sparse.c xxx.c # oh my lord :)
Note that I had to specify '/home/ramsay/' rather than just '~', since it does not get recognized/expanded in that position:
$ clang-format --style=file:~/git/.clang-format sparse.c >xxx.c Error reading ~/git/.clang-format: No such file or directory $ rm xxx.c
Also, as you can see, this was 'clang-format' not 'git-clang-format' (which is what would actually be used in this situation), but the '--help' text claims that:
$ git-clang-format --help | grep style
clangFormat.style
--style STYLE passed to clang-format
$ .. so it should work (but I have not actually tried it, so YMMV ;) ).
[So, munging the .clang-format file with sed (say) to a temp file and using the --style=file:tmp-file syntax should (hopefully) work]
ATB, Ramsay Jones