bug-diffutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-diffutils] [PATCH] Add --ed-line-numbers-only option to diff


From: Niklas Hambüchen
Subject: [bug-diffutils] [PATCH] Add --ed-line-numbers-only option to diff
Date: Mon, 15 Aug 2011 03:38:18 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20110627 Thunderbird/5.0

Hello,

in a recent file system failure, I lost quite a bit of work on Gtk, so I wrote a program that helps finding lost file names (e.g. as a result of a system recovery like extundelete) by comparing them to similar files.

To calculate the similarity of files, I compare the number of common lines between to files to their sizes. To find that number of common lines, I use (ah, finally...) diff.

I found it quite interesting that I had to spend hours searching for a program to just tell how many lines of two files are the same, or more generally, to tell me which parts of two files are the same and where exactly additions, deletions and replacements are.

After some time, I finally found the diff -e flag, that prints out the ed (ed is the standard editor!) commands to transform the one file into the other. This information can nicely be used to calculate all these things (it indeed already prints out additions, deletions and replacements in a line-based fashion, so that only the similar hunks have to be calculated off that data). However, it also prints out the actual file (change) content, which is a mess to parse, even more if you are not interested in the result.

I therefore propose the following patch that implements a --ed-line-numbers-only option to omit the contents and only print out the difference location information.

Thank you
Niklas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]