Git Diff Indent / Pretty Print / Beautify Before Diff [英] Git Diff Indent/Pretty Print/Beautify Before Diff
问题描述
有没有办法让Git 缩进
/ beautify / pretty打印两个版本的C ++源文件,然后再进行区分?
我认为我的目标是显而易见的:我不想让Git向我展示一些愚蠢的IDE在一些猴子(像我)命中自动格式化之后引入的无数变化。
用法示例:我找到 git difftool --indent-before-diffing path / to / file
,并获得原始版本 path / to / file
和修改后的版本 path / to / file
缩进。
如果您可以找到一个应用程序执行缩进,您可以使用此处用于odt文件:
将以下行添加到.gitattributes文件中:
*。odt diff = odt
现在在.git / config中设置odt diff过滤器:
[diffodt]
binary = true
textconv = / usr / local / bin / odt-to-txt
所以对于C ++文件,它会是这样:
*。cpp diff = cpp
git / config:
[diffcpp]
binary = true
textconv = / path / / indenter
正如注释中指出的, GNU Indent 可用于缩进。
Is there a way to make Git indent
/beautify/pretty print two versions of C++ source files before diffing them?
I think my goal is obvious: I don't want Git to show me the myriads of changes introduced by some stupid IDE after some monkey (like me) has hit auto-format.
Example usage: I hit git difftool --indent-before-diffing path/to/file
and get the changes after both the original version of path/to/file
and the modified version of path/to/file
have been indented.
If you can find an application that does the indenting for you, you could use the method described here for odt files:
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
So for C++ files it would be something like this:
*.cpp diff=cpp
And in the .git/config:
[diff "cpp"]
binary = true
textconv = /path/to/indenter
As pointed out in the comments, GNU Indent can be used for indenting.
这篇关于Git Diff Indent / Pretty Print / Beautify Before Diff的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!