git: 12a8d3027d41 - main - diff: honour flags with -q
Ed Maste
emaste at FreeBSD.org
Sat Jan 9 18:34:35 UTC 2021
The branch main has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=12a8d3027d414abd15798de1b6d8b01151bdac50
commit 12a8d3027d414abd15798de1b6d8b01151bdac50
Author: Ed Maste <emaste at FreeBSD.org>
AuthorDate: 2021-01-09 16:22:28 +0000
Commit: Ed Maste <emaste at FreeBSD.org>
CommitDate: 2021-01-09 18:34:06 +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
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28064
---
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
More information about the dev-commits-src-main
mailing list