有没有办法让 Git indent
/beautify/pretty 在 diff 之前打印两个版本的 C++ 源文件?
我不希望 Git 向我显示在有人自动格式化代码后引入的无数更改。
示例用法:我点击 git difftool --indent-before-diffing path/to/file
并在 path/to/file
的原始版本之后获取更改> 和 path/to/file
的修改版本已经缩进。
最佳答案
如果您能找到为您缩进的应用程序,您可以使用描述的方法 here对于 odt 文件:
Add the following line to your .gitattributes file:
*.odt diff=odt
Now set up the odt diff filter in .git/config:
[diff "odt"] binary = true textconv = /usr/local/bin/odt-to-txt
所以对于 C++ 文件,它将是这样的:
*.cpp diff=cpp
在 .git/config 中:
[diff "cpp"]
textconv = /path/to/indenter
正如评论中指出的那样,GNU Indent可用于缩进。
关于c++ - Git Diff Indent/Pretty Print/Beautify Before Diff,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16357375/