Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Jan 2021 14:26:59 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 7366c22508e9 - stable/12 - diff: honour flags with -q
Message-ID:  <202101151426.10FEQxZh013749@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=7366c22508e98357a17664b683841b47d268b5f8

commit 7366c22508e98357a17664b683841b47d268b5f8
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2021-01-09 16:22:28 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2021-01-15 14:25:35 +0000

    diff: honour flags with -q
    
    Previously -q (just print a line when files differ) ignored flags like
    -w (ignore whitespace).  Avoid the D_BRIEF short-circuit when flags are
    in effect.
    
    PR:             252515
    Reported by:    Scott Aitken
    Reviewed by:    kevans
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D28064
    
    (cherry picked from commit 12a8d3027d414abd15798de1b6d8b01151bdac50)
---
 usr.bin/diff/diffreg.c          |  4 +++-
 usr.bin/diff/tests/diff_test.sh | 10 ++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c
index 74c0df7dce30..7d2b20b43def 100644
--- a/usr.bin/diff/diffreg.c
+++ b/usr.bin/diff/diffreg.c
@@ -369,7 +369,9 @@ diffreg(char *file1, char *file2, int flags, int capsicum)
 		goto closem;
 	}
 
-	if (diff_format == D_BRIEF && ignore_pats == NULL) {
+	if (diff_format == D_BRIEF && ignore_pats == NULL &&
+	    (flags & (D_FOLDBLANKS|D_IGNOREBLANKS|D_IGNORECASE|D_STRIPCR)) == 0)
+	{
 		rval = D_DIFFER;
 		status |= 1;
 		goto closem;
diff --git a/usr.bin/diff/tests/diff_test.sh b/usr.bin/diff/tests/diff_test.sh
index 9f460231f480..7ee88d1fe607 100755
--- a/usr.bin/diff/tests/diff_test.sh
+++ b/usr.bin/diff/tests/diff_test.sh
@@ -9,6 +9,7 @@ atf_test_case group_format
 atf_test_case side_by_side
 atf_test_case brief_format
 atf_test_case b230049
+atf_test_case b252515
 atf_test_case Bflag
 atf_test_case Nflag
 atf_test_case tabsize
@@ -65,6 +66,14 @@ b230049_body()
 		    b230049_a.in b230049_b.in
 }
 
+b252515_body()
+{
+	printf 'a b\n' > b252515_a.in
+	printf 'a  b\n' > b252515_b.in
+	atf_check -o empty -s eq:0 \
+		diff -qw b252515_a.in b252515_b.in
+}
+
 header_body()
 {
 	export TZ=UTC
@@ -228,6 +237,7 @@ atf_init_test_cases()
 	atf_add_test_case side_by_side
 	atf_add_test_case brief_format
 	atf_add_test_case b230049
+	atf_add_test_case b252515
 	atf_add_test_case Bflag
 	atf_add_test_case Nflag
 	atf_add_test_case tabsize



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101151426.10FEQxZh013749>