git: 12ea2d04c379 - stable/13 - diff: honour -B flag with -q

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Fri, 07 Jun 2024 21:16:13 UTC
The branch stable/13 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=12ea2d04c37982cabf7865e8897226c81aae4ab0

commit 12ea2d04c37982cabf7865e8897226c81aae4ab0
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-05-16 14:53:23 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-06-07 21:15:57 +0000

    diff: honour -B flag with -q
    
    PR:             278988
    Reviewed by:    bapt
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D45220
    
    (cherry picked from commit fb623aab3927a6825ff7731198ec2e33426f7607)
    (cherry picked from commit 1b7672ed992963e1c79ccc152f4afd72c91481f3)
---
 usr.bin/diff/diffreg.c          |  3 ++-
 usr.bin/diff/tests/diff_test.sh | 10 ++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c
index 322c66c76839..a73020c44a80 100644
--- a/usr.bin/diff/diffreg.c
+++ b/usr.bin/diff/diffreg.c
@@ -374,7 +374,8 @@ diffreg(char *file1, char *file2, int flags, int capsicum)
 	}
 
 	if (diff_format == D_BRIEF && ignore_pats == NULL &&
-	    (flags & (D_FOLDBLANKS|D_IGNOREBLANKS|D_IGNORECASE|D_STRIPCR)) == 0)
+	    (flags & (D_FOLDBLANKS|D_IGNOREBLANKS|D_IGNORECASE|
+	    D_SKIPBLANKLINES|D_STRIPCR)) == 0)
 	{
 		rval = D_DIFFER;
 		status |= 1;
diff --git a/usr.bin/diff/tests/diff_test.sh b/usr.bin/diff/tests/diff_test.sh
index a3821b4deb2f..29ab0eaec161 100755
--- a/usr.bin/diff/tests/diff_test.sh
+++ b/usr.bin/diff/tests/diff_test.sh
@@ -10,6 +10,7 @@ atf_test_case brief_format
 atf_test_case b230049
 atf_test_case stripcr_o
 atf_test_case b252515
+atf_test_case b278988
 atf_test_case Bflag
 atf_test_case Nflag
 atf_test_case tabsize
@@ -85,6 +86,14 @@ b252515_body()
 		diff -qw b252515_a.in b252515_b.in
 }
 
+b278988_body()
+{
+	printf 'a\nb\nn' > b278988.a.in
+	printf 'a\n\nb\nn' > b278988.b.in
+	atf_check -o empty -s eq:0 \
+		diff -Bw b278988.a.in b278988.b.in
+}
+
 header_body()
 {
 	export TZ=UTC
@@ -288,6 +297,7 @@ atf_init_test_cases()
 	atf_add_test_case b230049
 	atf_add_test_case stripcr_o
 	atf_add_test_case b252515
+	atf_add_test_case b278988
 	atf_add_test_case Bflag
 	atf_add_test_case Nflag
 	atf_add_test_case tabsize