On Wed, 2011-01-12 at 15:00 +0000, Matthew King wrote:
> GNU diff has an option described thusly:
> 
>        -I RE  --ignore-matching-lines=RE
>               Ignore changes whose lines all match RE.
> 
> Fantastic, says you, now I can compare two files and see only if lines 
> which aren't comments differ by telling diff to ignore lines which 
> begin with a '#'.
> 
> No, says GNU, that is useful functionality which would be the logical 
> extension of *all* the other 'ignore' options diff accepts. What -I RE 
> will do instead is indicate that *the entire file* does not differ iff 
> *all differing lines* match the regular expression. In the highly 
> likely situation that lines which match your expression differ *and* 
> lines which don't match differ, you will see every line of difference, 
> whether it matches or not.
> 
> Hate.

I don't think you read it literally enough. It applies to a chunk not
the whole file. It ignores chunks where all changed lines match the
regexp.

eg.

diff -u a b
--- a   2011-01-13 02:10:53.000000000 +1030
+++ b   2011-01-13 02:11:14.000000000 +1030
@@ -1,4 +1,4 @@
-abc
+abd
 abc
 ddd
 ddd
@@ -7,5 +7,5 @@
 eee
 eee
 ddd
-ddd
+ddc
 ddd

# diff -u -I b a b
--- a   2011-01-13 02:10:53.000000000 +1030
+++ b   2011-01-13 02:11:14.000000000 +1030
@@ -7,5 +7,5 @@
 eee
 eee
 ddd
-ddd
+ddc
 ddd

It's still hateful though because if it behaved how you expected it to
it'd be a lot more useful. It's easy to see how it was simpler to
implement the way it does work though, so the option is really a bad
hack.

Cheers,
Martin


Reply via email to