please consider using clang-format for consistent code styling

Comments, questions, bug reports, etc.
Post Reply
x5a17ed
Posts: 2
Joined: Wed May 31, 2023 8:45 am

please consider using clang-format for consistent code styling

Post by x5a17ed »

Hi,

I would like to contribute a line changes that I'm currently working on back to the upstream of this project. My intentions are to be as unintrusive as possible with these changes. Unfortunately there are no written contribution guidelines available yet though. Therefore I assume that the bare minimum are that the changes are tested, obviously and that a coherent code style is adhered to. For this reason I would like to ask kindly though if it was possible to either agree on a common code styling convention such as GNU or the Linux Kernel's or codify the current code styling convention into a clang-format configuration file. That would be very helpful to ensure that the changes do not look out of line with the rest of the project at least. One way how this could look like is show-cased here: https://github.com/0x5a17ed/wimlib/tree/clang-format.

What are your thoughts?
synchronicity
Site Admin
Posts: 472
Joined: Sun Aug 02, 2015 10:31 pm

Re: please consider using clang-format for consistent code styling

Post by synchronicity »

wimlib uses the Linux kernel coding style. (There are a couple minor differences, but don't worry about them.) Please don't change it to the GNU coding style.

I can add a clang-format file. But I'm not sure I want to reformat the entire codebase. A clang-format file can be added for use by 'git clang-format', without reformatting the entire codebase.
x5a17ed
Posts: 2
Joined: Wed May 31, 2023 8:45 am

Re: please consider using clang-format for consistent code styling

Post by x5a17ed »

wimlib uses the Linux kernel coding style. (There are a couple minor differences, but don't worry about them.) Please don't change it to the GNU coding style.
I adjusted the previously linked branch on github to use a clang-format file that was taken from the linux kernel code base plus a few changes to make the output of clang-format look closer to what the current source code looks like. It's far from being perfect or the same what the current code actually looks like but I guess it's a starting point.
I can add a clang-format file. But I'm not sure I want to reformat the entire codebase. A clang-format file can be added for use by 'git clang-format', without reformatting the entire codebase.
It's just that adding a clang-format file would be helpful to me to ensure in an automated way via a tool that the changes I make are in line with what the general coding style is. I personally really like what 'go fmt' does for that matter. But I would like to not discuss the merits of a code formatting tool here.

It's not necessary to reformat the entire code base. VSCode/Codium supports formatting only new changes just like 'git clang-format' as well. So this is not a concern of mine. Formatting the code base in that branch is more of a method to show case how the clang-format would affect code formatting.
synchronicity
Site Admin
Posts: 472
Joined: Sun Aug 02, 2015 10:31 pm

Re: please consider using clang-format for consistent code styling

Post by synchronicity »

Post Reply