[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to exclude certain hunk types (added, changed, deleted) from dif
From: |
Matthew Woehlke |
Subject: |
Re: How to exclude certain hunk types (added, changed, deleted) from diff |
Date: |
Wed, 26 Sep 2007 23:33:55 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.0 |
Alexander Kriegisch wrote:
* Atention, this is not a bug report but a question not answered by the
manual. If there is an official discussion mailing list for this type of
inquiry, I beg your pardon and kindly ask you to point me to that list
or forum. *
I have a special case here in which I am getting huge diff outputs, but
am interested only in deleted and changed hunks, not added hunks.
Unfortunately, the latter make up >90% of my diff, resulting in the
interesting parts being hard to find.
[snip]
Is there a simple way of telling diff to exclude a/d/c hunks from
output, but show the remainder in a uni-diff-like fashion? Filtering a
complete uni-diff with sed or grep is hard, because those tools do not
have a multi-line regex matching mode which would be needed to do it.
Any ideas?
This should be do-able with sed, something like this:
identify hunk start, print buffer and goto a
:a
examine line
if desirable hunk, goto b
if not end of hunk, goto a
delete buffer
goto start
:b
read until end of hunk
print buffer
goto start
...terrible pseudo-code of course, but I've done complex sed like this
before. Depending on your needs you may need to make (a) print and (b)
discard.
Ideal? Probably not, but do-able.
--
Matthew
"Passion is inversely proportional to the amount of real information
available." -- Benford's Law of Controversy
http://en.wikipedia.org/wiki/Benford%27s_law_of_controversy