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 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.

Need Your Help

Crystal's rpt published to the wrong folder visual-studio-2010 crystal-reports

I am using ASP.NET MVC 2 in Visual Studio 2010. In my project I have created a 'Crystal' folder containing crystal reports .rpt files. I have set the 'build action' of each .rpt files to 'Content',

Youtube Playlist API feed doesn't include restricted videos

api youtube playlist restriction

Basically what I'm trying to do is to download all the video's metadata from this playlist

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.