git clang-format
is a handy tool to run clang-format
on only the lines touched by a git patch. I want to stop myself accidentally committing and pushing patches that I've forgotten to run git-clang-format on. E.g. by adding a check to .git/hooks/pre-commit
that makes sure git clang-format HEAD~1
has nothing to do. However it doesn't look like the return code ever changes.
clang-format
itself has --dry-run -Werror
: Can clang-format tell me if formatting changes are necessary?
Unfortunately it doesn't look like git-clang-format supports it, or has a way to forward on the argument. Is there a programmatic way to know if there are changes?
$ git clang-format -Werror --diff HEAD~1 -q
usage: git clang-format [OPTIONS] [<commit>] [<commit>] [--] [<file>...]
git-clang-format: error: unrecognized arguments: -Werror