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
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28064
This commit is contained in:
Ed Maste 2021-01-09 11:22:28 -05:00
parent 40e6e2c2f7
commit 12a8d3027d
2 changed files with 13 additions and 1 deletions

View File

@ -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;

View File

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