From MAILER-DAEMON Thu May 26 05:16:07 2022
Received: from list by lists.gnu.org with archive (Exim 4.90_1)
	id 1nu9bB-00079T-SB
	for mharc-bug-diffutils@gnu.org; Thu, 26 May 2022 05:16:07 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59602)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1nu9b8-00076P-Ls
 for bug-diffutils@gnu.org; Thu, 26 May 2022 05:16:02 -0400
Received: from debbugs.gnu.org ([209.51.188.43]:34933)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1nu9b8-0000hl-Bw
 for bug-diffutils@gnu.org; Thu, 26 May 2022 05:16:02 -0400
Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1nu9b8-0005lb-8M
 for bug-diffutils@gnu.org; Thu, 26 May 2022 05:16:02 -0400
X-Loop: help-debbugs@gnu.org
Resent-From: Harald Dunkel <harri@afaics.de>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-diffutils@gnu.org
Resent-Date: Thu, 26 May 2022 09:16:02 +0000
Resent-Message-ID: <handler.55652.B.165355655822143@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: report 55652
X-GNU-PR-Package: diffutils
X-GNU-PR-Keywords: 
To: 55652@debbugs.gnu.org
X-Debbugs-Original-To: bug-diffutils@gnu.org
Received: via spool by submit@debbugs.gnu.org id=B.165355655822143
 (code B ref -1); Thu, 26 May 2022 09:16:02 +0000
Received: (at submit) by debbugs.gnu.org; 26 May 2022 09:15:58 +0000
Received: from localhost ([127.0.0.1]:57061 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1nu9b4-0005l5-2v
 for submit@debbugs.gnu.org; Thu, 26 May 2022 05:15:58 -0400
Received: from lists.gnu.org ([209.51.188.17]:59040)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <harri@afaics.de>) id 1nu9b2-0005ky-NA
 for submit@debbugs.gnu.org; Thu, 26 May 2022 05:15:56 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59586)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <harri@afaics.de>) id 1nu9b2-0006uE-Ee
 for bug-diffutils@gnu.org; Thu, 26 May 2022 05:15:56 -0400
Received: from mordac.selfhost.de ([82.98.82.6]:55247
 helo=outgoing.selfhost.de)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <harri@afaics.de>) id 1nu9b0-0000gN-FW
 for bug-diffutils@gnu.org; Thu, 26 May 2022 05:15:56 -0400
Received: (qmail 5098 invoked from network); 26 May 2022 09:15:39 -0000
Received: from unknown (HELO mailhost.afaics.de)
 (postmaster@xqrsonfo.mail.selfhost.de@87.160.253.127)
 by mailout.selfhost.de with ESMTPA; 26 May 2022 09:15:39 -0000
Received: from [10.42.100.14] (cecil.afaics.de [10.42.100.14])
 by marvin.afaics.de (OpenSMTPD) with ESMTP id 41afc141;
 Thu, 26 May 2022 11:15:39 +0200 (CEST)
Message-ID: <1d037236-055e-ffa8-7624-ede9ea58b009@afaics.de>
Date: Thu, 26 May 2022 11:15:39 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.9.1
Content-Language: en-US
From: Harald Dunkel <harri@afaics.de>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Received-SPF: none client-ip=82.98.82.6; envelope-from=harri@afaics.de;
 helo=outgoing.selfhost.de
X-Spam_score_int: -25
X-Spam_score: -2.6
X-Spam_bar: --
X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7,
 SPF_HELO_NONE=0.001, SPF_NONE=0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
Errors-To: debbugs-submit-bounces@debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
X-Spam-Score: -3.3 (---)
Subject: [bug-diffutils] bug#55652: please elaborate on diff -u -I RE
X-BeenThere: bug-diffutils@gnu.org
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
 <mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
 <mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 26 May 2022 09:16:03 -0000

Hi folks,

I have hoped that

	diff -I '^[[:space:]]*\#' file1 file2

would ignore comment lines, but it doesn't work as I expected.
Example:

	#!/bin/bash

	diff -version | head -1

	echo -e '\t# comment 1' >/tmp/x1
	echo -e '\t# comment 2' >/tmp/x2
	diff -u -I '^[[:space:]]*\#' /tmp/x1 /tmp/x2 && echo 'no diffs'

	echo -e '' >>/tmp/x1
	echo -e '' >>/tmp/x2
	diff -u -I '^[[:space:]]*\#' /tmp/x1 /tmp/x2 && echo 'still no diffs'

	echo -e 'hello, world' >>/tmp/x2
	diff -u -I '^[[:space:]]*\#' /tmp/x1 /tmp/x2 && echo 'no diffs'
	echo "diff --normal"
	diff -I '^[[:space:]]*\#' /tmp/x1 /tmp/x2 && echo 'no diffs'

Output:

	diff (GNU diffutils) 3.8
	no diffs
	still no diffs
	--- /tmp/x1     2022-05-26 10:54:36.187361365 +0200
	+++ /tmp/x2     2022-05-26 10:54:36.191361276 +0200
	@@ -1,2 +1,3 @@
	-       # comment 1
	+       # comment 2
	
	+hello, world
	diff --normal
	2a3
	> hello, world

This seems weird. Only 1 line has been appended to x2 before running
diff the third time. It does not match the pattern. How comes diff -u
reports 2 different lines, with an unchanged line in between? Is this
as expected?


Regards

Harri




From MAILER-DAEMON Thu May 26 21:54:05 2022
Received: from list by lists.gnu.org with archive (Exim 4.90_1)
	id 1nuPAz-0004lg-AO
	for mharc-bug-diffutils@gnu.org; Thu, 26 May 2022 21:54:05 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:60260)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1nuPAx-0004kq-1D
 for bug-diffutils@gnu.org; Thu, 26 May 2022 21:54:03 -0400
Received: from debbugs.gnu.org ([209.51.188.43]:38253)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1nuPAw-0006ep-Oi
 for bug-diffutils@gnu.org; Thu, 26 May 2022 21:54:02 -0400
Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1nuPAw-0004lb-HW
 for bug-diffutils@gnu.org; Thu, 26 May 2022 21:54:02 -0400
Resent-From: Paul Eggert <eggert@cs.ucla.edu>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-To: bug-diffutils@gnu.org
Resent-Date: Fri, 27 May 2022 01:54:02 +0000
Resent-Message-ID: <handler.55652.D55652.165361641118279.done@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: cc-closed 55652
X-GNU-PR-Package: diffutils
X-GNU-PR-Keywords: 
To: Harald Dunkel <harri@afaics.de>
Cc: 55652-done@debbugs.gnu.org
Mail-Followup-To: 55652@debbugs.gnu.org, eggert@cs.ucla.edu, harri@afaics.de
Received: via spool by 55652-done@debbugs.gnu.org id=D55652.165361641118279
 (code D ref 55652); Fri, 27 May 2022 01:54:02 +0000
Received: (at 55652-done) by debbugs.gnu.org; 27 May 2022 01:53:31 +0000
Received: from localhost ([127.0.0.1]:60383 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1nuPAQ-0004kl-Mx
 for submit@debbugs.gnu.org; Thu, 26 May 2022 21:53:30 -0400
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:45172)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@cs.ucla.edu>) id 1nuPAO-0004kU-GR
 for 55652-done@debbugs.gnu.org; Thu, 26 May 2022 21:53:29 -0400
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id AEE8F160137;
 Thu, 26 May 2022 18:53:21 -0700 (PDT)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id oKohj5PLSSip; Thu, 26 May 2022 18:53:21 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 06766160139;
 Thu, 26 May 2022 18:53:21 -0700 (PDT)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id pDdFxZ8Zdtf1; Thu, 26 May 2022 18:53:20 -0700 (PDT)
Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id D81A8160137;
 Thu, 26 May 2022 18:53:20 -0700 (PDT)
Message-ID: <67d65b7a-1438-9033-e331-6791bc0043f8@cs.ucla.edu>
Date: Thu, 26 May 2022 18:53:20 -0700
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.9.0
Content-Language: en-US
References: <1d037236-055e-ffa8-7624-ede9ea58b009@afaics.de>
From: Paul Eggert <eggert@cs.ucla.edu>
Organization: UCLA Computer Science Department
In-Reply-To: <1d037236-055e-ffa8-7624-ede9ea58b009@afaics.de>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
Errors-To: debbugs-submit-bounces@debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
X-Spam-Score: -3.3 (---)
Subject: [bug-diffutils] bug#55652: bug#55652: please elaborate on diff -u
 -I RE
X-BeenThere: bug-diffutils@gnu.org
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
 <mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
 <mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 27 May 2022 01:54:03 -0000

On 5/26/22 02:15, Harald Dunkel wrote:
> How comes diff -u
> reports 2 different lines, with an unchanged line in between?

What else can diff do? You asked for context, and the context lines differ.


> Is this
> as expected? 

Yes, the manual says:

    However, '-I' only ignores the insertion or deletion of lines that
contain the regular expression if every changed line in the hunk--every
insertion and every deletion--matches the regular expression.  In other
words, for each nonignorable change, 'diff' prints the complete set of
changes in its vicinity, including the ignorable ones.


One might add an option to make diff behave differently in this case, 
although it's not clear what the "right" behavior would be. In the 
meantime perhaps you can get by with "diff -U0 -Iwhatever".




From MAILER-DAEMON Fri May 27 03:55:06 2022
Received: from list by lists.gnu.org with archive (Exim 4.90_1)
	id 1nuUoM-00066N-D5
	for mharc-bug-diffutils@gnu.org; Fri, 27 May 2022 03:55:06 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:51798)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1nuUoI-00065T-Ef
 for bug-diffutils@gnu.org; Fri, 27 May 2022 03:55:02 -0400
Received: from debbugs.gnu.org ([209.51.188.43]:38704)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1nuUoI-0004Qg-5G
 for bug-diffutils@gnu.org; Fri, 27 May 2022 03:55:02 -0400
Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1nuUoI-00082d-3L
 for bug-diffutils@gnu.org; Fri, 27 May 2022 03:55:02 -0400
X-Loop: help-debbugs@gnu.org
Resent-From: Harald Dunkel <harri@afaics.de>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-diffutils@gnu.org
Resent-Date: Fri, 27 May 2022 07:55:02 +0000
Resent-Message-ID: <handler.55652.D55652.165363804630836@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 55652
X-GNU-PR-Package: diffutils
X-GNU-PR-Keywords: 
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: 55652-done@debbugs.gnu.org
Received: via spool by 55652-done@debbugs.gnu.org id=D55652.165363804630836
 (code D ref 55652); Fri, 27 May 2022 07:55:02 +0000
Received: (at 55652-done) by debbugs.gnu.org; 27 May 2022 07:54:06 +0000
Received: from localhost ([127.0.0.1]:60834 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1nuUnH-00080t-1m
 for submit@debbugs.gnu.org; Fri, 27 May 2022 03:54:06 -0400
Received: from mordac.selfhost.de ([82.98.82.6]:38037
 helo=outgoing.selfhost.de)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <harri@afaics.de>) id 1nuUnF-00080k-4W
 for 55652-done@debbugs.gnu.org; Fri, 27 May 2022 03:53:57 -0400
Received: (qmail 10322 invoked from network); 27 May 2022 07:53:55 -0000
Received: from unknown (HELO mailhost.afaics.de)
 (postmaster@xqrsonfo.mail.selfhost.de@87.160.253.127)
 by mailout.selfhost.de with ESMTPA; 27 May 2022 07:53:55 -0000
Received: from [10.42.100.14] (cecil.afaics.de [10.42.100.14])
 by marvin.afaics.de (OpenSMTPD) with ESMTP id ffe075ec;
 Fri, 27 May 2022 09:53:55 +0200 (CEST)
Message-ID: <afeefbc2-1c48-f05c-2044-e4202a6bd4aa@afaics.de>
Date: Fri, 27 May 2022 09:53:55 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.9.1
From: Harald Dunkel <harri@afaics.de>
References: <1d037236-055e-ffa8-7624-ede9ea58b009@afaics.de>
 <67d65b7a-1438-9033-e331-6791bc0043f8@cs.ucla.edu>
Content-Language: en-US
In-Reply-To: <67d65b7a-1438-9033-e331-6791bc0043f8@cs.ucla.edu>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.7 (/)
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
Errors-To: debbugs-submit-bounces@debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
X-Spam-Score: -1.7 (-)
Subject: [bug-diffutils] bug#55652: bug#55652: please elaborate on diff -u
 -I RE
X-BeenThere: bug-diffutils@gnu.org
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
 <mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
 <mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 27 May 2022 07:55:04 -0000

Hi Paul,

On 2022-05-27 03:53:20, Paul Eggert wrote:
> On 5/26/22 02:15, Harald Dunkel wrote:
>> How comes diff -u
>> reports 2 different lines, with an unchanged line in between?
> 
> What else can diff do? You asked for context, and the context lines differ.
> 

It could show the old ignored lines as unchanged, of course. This would allow
to apply the diff using patch. If it would show the new ignored lines instead,
then you could only reverse apply the diff, which is much less likely to be
useful. In the current implementation it is not useful at all.

> 
>> Is this
>> as expected?
> 
> Yes, the manual says:
> 
>      However, '-I' only ignores the insertion or deletion of lines that
> contain the regular expression if every changed line in the hunk--every
> insertion and every deletion--matches the regular expression.  In other
> words, for each nonignorable change, 'diff' prints the complete set of
> changes in its vicinity, including the ignorable ones.
> 

Where did you find this? The man page for diffutils 3.8 doesn't tell.


Regards

Harri




