On Thu, 13 Jan 2011 02:15:16 +1030, Martin Ebourne
<[email protected]> wrote:
> 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.

s/entire file/entire chunk/

Hate remains secure.

> 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.

I'm not sure I agree that it's easier. There is already code somewhere
along the lines of.

if (line_a != line_b) {
  if (ignore_case && lc_line_a == lc_line_b)
    return no_diff;
  if (ignore_blank_lines && line_a == '' || line_b == '')
    return no_diff;
  if (ignore_spaces && line_a_without_spaces == line_b_without_spaces)
    return no_diff;
  etc.
}

Surely the easier thing to do is just add another check for the
ignore_match flag. -I RE is the only option I can see which compares an
entire chunk.

Matthew


Reply via email to