【发布时间】:2022-10-15 04:59:44
【问题描述】:
git clang-format 是一个方便的工具,可以仅在 git 补丁触及的行上运行 clang-format。我想阻止自己不小心提交和推送我忘记运行 git-clang-format 的补丁。例如。通过向.git/hooks/pre-commit 添加一个检查,确保git clang-format HEAD~1 无事可做。但是,返回代码看起来并没有改变。
clang-format本身有--dry-run -Werror:Can clang-format tell me if formatting changes are necessary?
不幸的是,它看起来不像 git-clang-format 支持它,或者有办法转发参数。有没有一种程序化的方式来知道是否有变化?
$ git clang-format -Werror --diff HEAD~1 -q
usage: git clang-format [OPTIONS] [<commit>] [<commit>] [--] [<file>...]
git-clang-format: error: unrecognized arguments: -Werror
【问题讨论】:
标签: git clang-format