Git Diff indent / Pretty Print / Beautify Before Diff

Is there a way to make Git indent / beautify / pretty print two versions of C ++ source files before distinguishing them?

I think my goal is obvious: I do not want Git to show me a lot of changes made by some kind of stupid environment after some monkey (like me) got into automatic format.

Usage example: I git difftool --indent-before-diffing path/to/file and get the changes after the original version of path/to/file and the modified version of path/to/file were indented.

+6
c ++ git pretty-print indentation
May 03 '13 at 11:00
source share
1 answer

If you can find an application that is indenting for you, you can use the method described here for odt files:

Add the following line to the .gitattributes file:

*.odt diff=odt

Now configure the odt diff filter in .git / config:

 [diff "odt"] binary = true textconv = /usr/local/bin/odt-to-txt 

So for C ++ files it will be something like this:

 *.cpp diff=cpp 

And in .git / config:

 [diff "cpp"] binary = true textconv = /path/to/indenter 

As pointed out in the comments, GNU Indent can be used for indentation.

+8
16 at 11:06
source share



All Articles