At Undo, the company where I work, we have a quite big C codebase with a not very consistent style.
To improve things, we decided to use the
clang-format tool (part of the LLVM projects) to enforce a consistent style for new and refactored code.
We don’t want to change all the existing code to avoid a massive and confusing change, and we don’t want spurious unrelated changes when somebody modifies a file.
To achieve this, I wrote a couple of scripts which, using
clang-format-diff, only modify the formatting of the code you are about to commit.
The most interesting part is, I think, the pre-commit hook which suggests fixes before your code is committed:
This code is now available in the clang-format-hooks repository on GitHub.