How to ignore coding convention/style while generating diff using svn?
How can we ignore coding convention while generating diff using svn?
To elaborate, I do not want to distinguish between the following two coding styles
while (variableIter.hasNext())
{
lModel = variableIter.next();
}
AND
while (variableIter.hasNext()) {
lModel = variableIter
.next();
}
If I run a svn diff,开发者_开发百科 I'll get the following diff:
- while (variableIter.hasNext())
- {
- lModel = variableIter.next();
+ while (variableIter.hasNext()) {
+ lModel = variableIter
+ .next();
But I do not want this to be part of the diff. I'd like svn to ignore this kind of coding style differences. So, is there any option in svn which can help me do this? OR is there a script or something I could run on the svn generated diff to spit out only real changes and not the coding style changes?
TIA
I don't know if svn has a builtin function to do that. Anyway you could use some tool to uniformily indent your code before submitting, like the indent tool for C (http://www.gnu.org/software/indent/).
Or you can try to launch the diff with this option:
svn diff -x -w
I can't help with the diff produced directly by subversion.
But once you realize the differences you are seeing are formatting related, then you might swith to an alternative diff'ing tools. See our Smart Differencer tools. These tools are language-specific. They work by parsing the language and build abstract syntax trees, and then comparing the trees. That makes them completely whitespace (and comment) insenstitive; reformatting the code doesn't show up as a difference. The diffs are reported as language elements (operand, expression, statement, declaration, block, method, class, ...) and editing actions (move, delete, insert, copy, rename-variable-within block and are precise to the start line/column and end line/column.
We presently have SmartDifferencers for many languages, including C, C++, C#, Java, JavaScript, PHP.
精彩评论