How to ignore moved lines in a diff

Posted by klickverbot on Super User See other posts from Super User or by klickverbot
Published on 2010-09-05T14:57:37Z Indexed on 2012/06/26 21:20 UTC
Read the original article Hit count: 236

Filed under:

I am currently working on a source code generation tool. To make sure that my changes do no introduce any new bugs, a diff between the output of the program before and after my changes would theoretically be a valuable tool.

However, this turns out to be harder than one might think, because the tool outputs lines where the order does not matter (like import statements, function declarations, …) in a semi-randomly ordered way. Because of this, the output of diff is cluttered with many changes that are in fact only lines moved to another position in the same file.

Is there a way to make diff ignore these moves and only output the lines that have really been added or removed?

© Super User or respective owner

Related posts about diff