GNU bug report logs - #18076
Lines are not ignored by option -I if they are followed by a line with a difference

Previous Next

Package: diffutils;

Reported by: Jean-Francois Thuong <jean-francois.thuong <at> esterel-technologies.com>

Date: Tue, 22 Jul 2014 08:02:02 UTC

Severity: normal

Tags: notabug

Found in version 3.3

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18076 in the body.
You can then email your comments to 18076 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-diffutils <at> gnu.org:
bug#18076; Package diffutils. (Tue, 22 Jul 2014 08:02:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jean-Francois Thuong <jean-francois.thuong <at> esterel-technologies.com>:
New bug report received and forwarded. Copy sent to bug-diffutils <at> gnu.org. (Tue, 22 Jul 2014 08:02:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jean-Francois Thuong <jean-francois.thuong <at> esterel-technologies.com>
To: submit <at> debbugs.gnu.org
Subject: Lines are not ignored by option -I if they are followed by a line
 with a difference
Date: Tue, 22 Jul 2014 14:59:43 +0800
[Message part 1 (text/plain, inline)]
Package: diffutils
Version: 3.3

When 2 (or more) consecutive lines are different between the two compared
files, they are ignored by option -I if all of them are ignored; if the
last line is not ignored, all the lines are returned by diff tool (instead
of only the last line).

Although the documentation clearly indicates this as nominal, it looks
strange while looking at the results to have lines that we supposed to have
been ignored.


------------------
To reproduce:
1. Create 2 files (e.g. File1.txt and File2.txt) having 2 consecutive
different lines (e.g. lines 2 and 3)
2. Run diff with option -I including a pattern matching line 2
3. Observe that diff returns differences for both lines 2 and 3


Note: the files attached could be used as an example with the command line
diff -I "^IGNORE:.*quot; File1.txt File2.txt
The difference is as follows:
2,3c2,3
< IGNORE: Line to be ignored with value = 1
< Different line (version A)
---
> IGNORE: Line to be ignored with value = 2
> Different line (version B)


Jean-Francois Thuong
------------------------------

[signature removed by request]

[Message part 2 (text/html, inline)]
[File1.txt (text/plain, attachment)]
[File2.txt (text/plain, attachment)]

Added tag(s) notabug. Request was from Eric Blake <eblake <at> redhat.com> to control <at> debbugs.gnu.org. (Tue, 22 Jul 2014 17:00:03 GMT) Full text and rfc822 format available.

Reply sent to Eric Blake <eblake <at> redhat.com>:
You have taken responsibility. (Tue, 22 Jul 2014 17:00:06 GMT) Full text and rfc822 format available.

Notification sent to Jean-Francois Thuong <jean-francois.thuong <at> esterel-technologies.com>:
bug acknowledged by developer. (Tue, 22 Jul 2014 17:00:07 GMT) Full text and rfc822 format available.

Message #12 received at 18076-done <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Jean-Francois Thuong <jean-francois.thuong <at> esterel-technologies.com>,
 18076-done <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#18076: Lines are not ignored by option -I
 if they are followed by a line with a difference
Date: Tue, 22 Jul 2014 10:58:58 -0600
[Message part 1 (text/plain, inline)]
tag 18076 notabug
thanks

On 07/22/2014 12:59 AM, Jean-Francois Thuong wrote:

> To reproduce:
> 1. Create 2 files (e.g. File1.txt and File2.txt) having 2 consecutive
> different lines (e.g. lines 2 and 3)
> 2. Run diff with option -I including a pattern matching line 2
> 3. Observe that diff returns differences for both lines 2 and 3

Thanks for the report.  However, this is not a bug, but documented
behavior.  -I only suppresses entire hunks where EVERY difference in the
hunk matches the regex.

The mode of operation you are requesting, where diff ignores lines that
match the regex prior to doing the comparison (although line numbers are
then a bit off), can be accomplished via this trick in bash:

patt='^IGNORE:'
diff <(sed "/$patt/d" File1.txt) <(sed "/$patt/d" File2.txt)

Maybe it's worth a new option to diff to allow this mode of operation by
default (and so that line numbers are still accurate); but -I cannot be
changed semantics to match that new option.

I'm closing this report as we are matching our documentation, although
we can reopen it if someone is interested in writing a patch for such a
new option.

> *The information transmitted is intended only for the person or entity to

Sorry, but such disclaimers are unenforceable on publicly-archived
mailing lists.  You may want to consider sending from a personal account
in the future, rather than slamming the list with your employer's
legalese spam.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-diffutils <at> gnu.org:
bug#18076; Package diffutils. (Wed, 23 Jul 2014 07:54:02 GMT) Full text and rfc822 format available.

Message #15 received at 18076 <at> debbugs.gnu.org (full text, mbox):

From: Jean-Francois Thuong <jean-francois.thuong <at> esterel-technologies.com>
To: 18076 <at> debbugs.gnu.org
Cc: Jean-Francois Thuong <jean-francois.thuong <at> esterel-technologies.com>
Subject: Re: bug#18076: closed (Re: [bug-diffutils] bug#18076: Lines are not
 ignored by option -I if they are followed by a line with a difference)
Date: Wed, 23 Jul 2014 15:52:44 +0800
[Message part 1 (text/plain, inline)]
Hello Eric,

Thank you for the tweak using sed; I suppose a similar "grep" would work as
well?

May i enter a request for enhancement with a suggestion to add this new
function enabling the filter of ignored lines from hunks containing
differences?



> *The information transmitted is intended only for the person or entity to
> Sorry, but such disclaimers are unenforceable on publicly-archived
> mailing lists.  You may want to consider sending from a personal account
> in the future, rather than slamming the list with your employer's
> legalese spam.


My bad. I unfortunately had to send the request from the company email
because this bug report was part of our process of the qualification of GNU
Diff 2.8.7.

Jean-Francois Thuong



On Wed, Jul 23, 2014 at 1:00 AM, GNU bug Tracking System <
help-debbugs <at> gnu.org> wrote:

> Your bug report
>
> #18076: Lines are not ignored by option -I if they are followed by a line
> with a difference
>
> which was filed against the diffutils package, has been closed.
>
> The explanation is attached below, along with your original report.
> If you require more details, please reply to 18076 <at> debbugs.gnu.org.
>
> --
> 18076: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18076
> GNU Bug Tracking System
> Contact help-debbugs <at> gnu.org with problems
>
>
> ---------- Forwarded message ----------
> From: Eric Blake <eblake <at> redhat.com>
> To: Jean-Francois Thuong <jean-francois.thuong <at> esterel-technologies.com>,
> 18076-done <at> debbugs.gnu.org
> Cc:
> Date: Tue, 22 Jul 2014 10:58:58 -0600
> Subject: Re: [bug-diffutils] bug#18076: Lines are not ignored by option -I
> if they are followed by a line with a difference
> tag 18076 notabug
> thanks
>
> On 07/22/2014 12:59 AM, Jean-Francois Thuong wrote:
>
> > To reproduce:
> > 1. Create 2 files (e.g. File1.txt and File2.txt) having 2 consecutive
> > different lines (e.g. lines 2 and 3)
> > 2. Run diff with option -I including a pattern matching line 2
> > 3. Observe that diff returns differences for both lines 2 and 3
>
> Thanks for the report.  However, this is not a bug, but documented
> behavior.  -I only suppresses entire hunks where EVERY difference in the
> hunk matches the regex.
>
> The mode of operation you are requesting, where diff ignores lines that
> match the regex prior to doing the comparison (although line numbers are
> then a bit off), can be accomplished via this trick in bash:
>
> patt='^IGNORE:'
> diff <(sed "/$patt/d" File1.txt) <(sed "/$patt/d" File2.txt)
>
> Maybe it's worth a new option to diff to allow this mode of operation by
> default (and so that line numbers are still accurate); but -I cannot be
> changed semantics to match that new option.
>
> I'm closing this report as we are matching our documentation, although
> we can reopen it if someone is interested in writing a patch for such a
> new option.
>
> > *The information transmitted is intended only for the person or entity to
>
> Sorry, but such disclaimers are unenforceable on publicly-archived
> mailing lists.  You may want to consider sending from a personal account
> in the future, rather than slamming the list with your employer's
> legalese spam.
>
> --
> Eric Blake   eblake redhat com    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
>
>
>
> ---------- Forwarded message ----------
> From: Jean-Francois Thuong <jean-francois.thuong <at> esterel-technologies.com>
> To: submit <at> debbugs.gnu.org
> Cc:
> Date: Tue, 22 Jul 2014 14:59:43 +0800
> Subject: Lines are not ignored by option -I if they are followed by a line
> with a difference
> Package: diffutils
> Version: 3.3
>
> When 2 (or more) consecutive lines are different between the two compared
> files, they are ignored by option -I if all of them are ignored; if the
> last line is not ignored, all the lines are returned by diff tool (instead
> of only the last line).
>
> Although the documentation clearly indicates this as nominal, it looks
> strange while looking at the results to have lines that we supposed to have
> been ignored.
>
>
> ------------------
> To reproduce:
> 1. Create 2 files (e.g. File1.txt and File2.txt) having 2 consecutive
> different lines (e.g. lines 2 and 3)
> 2. Run diff with option -I including a pattern matching line 2
> 3. Observe that diff returns differences for both lines 2 and 3
>
>
> Note: the files attached could be used as an example with the command line
> diff -I "^IGNORE:.*quot; File1.txt File2.txt
> The difference is as follows:
> 2,3c2,3
> < IGNORE: Line to be ignored with value = 1
> < Different line (version A)
> ---
> > IGNORE: Line to be ignored with value = 2
> > Different line (version B)
>
>
[Message part 2 (text/html, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 20 Aug 2014 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 303 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.