diff
usually produces rather clueless output. Here's a good example. If we start with this:
class World
def hello
puts "Hello, world"
end
def goodbye
puts "Goodbye, world"
end
end
Drop the second method and change the first:
class World
def hello
puts "Hello, #{self}"
end
end
diff -u
will be a total mess - suggesting two methods have been merged:
class World
def hello
- puts "Hello, world"
- end
- def goodbye
- puts "Goodbye, world"
+ puts "Hello, #{self}"
end
end
Instead of much more reasonable:
class World
def hello
- puts "Hello, world"
+ puts "Hello, #{self}"
end
- def goodbye
- puts "Goodbye, world"
- end
end
This is just a toy example, so diff
's output is still possible to understand - in practice it usually gets a lot worse.
Are there any alternatives to diff
that might be somewhat smarter?
The rfcdiff (Draft Diff Tool) reported this:
The tool uses GNU diff and wdiff.
You might consider our SD Smart Differencer. It provides differences based on the structure of the code rather than "line differences", so it is focused on language elements (expressions, statements, blocks, methods) and editing actions (delete, insert, copy, replace, rename).
It is language specific; it has to be to use language structure as a guide. It uses an explicit langauge definition. I can't quite tell what langauge you are using (Python?). There are Smart Differencer tools for many langauges, including C, C++, C#, Java, Python, Fortran, COBOL, ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With