@cmak , I wanted the same thing. @ben.boeckel walked through the philosophical/practical aspects of why this should not be done here.
You can configure a pre-commit hook for git
to run clang-format
over just the lines changed by the commit, but I don’t like doing that because that means I’m committing code I haven’t even tried to build.
What I ended up doing was changing my automated build (Bamboo) to run clang-format
over the entire source tree and fail if any file was modified. This makes the enforcement of formatting a CI step as Ben suggested; your build fails very quickly if you didn’t do the formatting like you should.