Thanks for the help! From all the replies, I think running the command as part of a file-locking mechanism (like flock
) would be the only viable solution. Platform compatibility is likely to be an issue (not sure if a readily-available equivalent would exist on Windows), but at least there is a solution.
Letting myself get sidetracked here: yes, for example, I’ve seen this post you’ve made about this specific point. In fact, that’s exactly why my CMake module adds support for git-clang-format
, rather than only plain clang-format
. I plan to use to introduce this to an existing codebase that isn’t formatted properly, and using normal clang-format
would require destroying version control history, even if we put the format checks only on the CI. Although, when using git-clang-format
in production, I’m not sure whether automatic fixes might introduce bugs in the code or not, with the whole “consider only the modified lines” thing. I would guess not, but git-clang-format
doesn’t seem too widely used so I wouldn’t trust it that easily.
This issue here is that, unlike normal clang-format
, git-clang-format
relies on git
, which breaks when multiple processes are run simultaneously.