mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-29 03:45:02 +01:00
diff: support -qq to output absolutely nothing
This is similar to `cmp -s`, but can be combined with: -B --ignore-blank-lines -b --ignore-space-change -w --ignore-all-space To only report a difference if it doesn't involve whitespace Reviewed by: des, bapt, markj (previous version), ziaee (man page) MFC after: 1 week Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D46717
This commit is contained in:
1 parent
1da1ad38d0
commit
c30a321a61
4 files changed
+20
-6
No files matched your search
+4
-1
@@ -30,7 +30,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd January 7, 2025
|
||||
.Dd October 12, 2026
|
||||
.Dt DIFF 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -319,6 +319,9 @@ This is the form used by rcsdiff.
|
||||
.It Fl q -brief
|
||||
Just print a line when the files differ.
|
||||
Does not output a list of changes.
|
||||
Specify twice
|
||||
.Pq Fl qq
|
||||
to output nothing at all, for when you only want to examine the exit code.
|
||||
.It Fl U Ar number Fl -unified Ar number
|
||||
Like
|
||||
.Fl u
|
||||
|
||||
+10
-3
@@ -276,7 +276,12 @@ main(int argc, char **argv)
|
||||
case 'q':
|
||||
if (FORMAT_MISMATCHED(D_BRIEF))
|
||||
conflicting_format();
|
||||
diff_format = D_BRIEF;
|
||||
if (diff_format == D_BRIEF) {
|
||||
diff_format = D_QUIET;
|
||||
/* If already D_QUIET, avoid getting more verbose. */
|
||||
} else if (diff_format != D_QUIET) {
|
||||
diff_format = D_BRIEF;
|
||||
}
|
||||
break;
|
||||
case 'S':
|
||||
start = optarg;
|
||||
@@ -474,8 +479,10 @@ main(int argc, char **argv)
|
||||
if (stat(argv[1], &stb2) == -1)
|
||||
err(2, "%s", argv[1]);
|
||||
}
|
||||
print_status(diffreg(argv[0], argv[1], dflags, 1), argv[0],
|
||||
argv[1], "");
|
||||
|
||||
if (diff_format != D_QUIET)
|
||||
print_status(diffreg(argv[0], argv[1], dflags, 1),
|
||||
argv[0], argv[1], "");
|
||||
}
|
||||
if (fflush(stdout) != 0)
|
||||
err(2, "stdout");
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#define D_BRIEF 6 /* Say if the files differ */
|
||||
#define D_GFORMAT 7 /* Diff with defined changed group format */
|
||||
#define D_SIDEBYSIDE 8 /* Side by side */
|
||||
#define D_QUIET 9 /* Don't output anything */
|
||||
|
||||
#define D_UNSET -2
|
||||
|
||||
|
||||
@@ -415,7 +415,8 @@ diffreg_stone(char *file1, char *file2, int flags, int capsicum)
|
||||
goto closem;
|
||||
}
|
||||
|
||||
if (diff_format == D_BRIEF && ignore_pats == NULL &&
|
||||
if ((diff_format == D_BRIEF || diff_format == D_QUIET) &&
|
||||
ignore_pats == NULL &&
|
||||
(flags & (D_FOLDBLANKS|D_IGNOREBLANKS|D_IGNORECASE|
|
||||
D_SKIPBLANKLINES|D_STRIPCR)) == 0)
|
||||
{
|
||||
@@ -1107,7 +1108,8 @@ restart:
|
||||
return;
|
||||
}
|
||||
proceed:
|
||||
if (*pflags & D_HEADER && diff_format != D_BRIEF) {
|
||||
if ((*pflags & D_HEADER) != 0 &&
|
||||
diff_format != D_BRIEF && diff_format != D_QUIET) {
|
||||
printf("%s %s %s\n", diffargs, file1, file2);
|
||||
*pflags &= ~D_HEADER;
|
||||
}
|
||||
@@ -1156,6 +1158,7 @@ proceed:
|
||||
anychange = 1;
|
||||
switch (diff_format) {
|
||||
case D_BRIEF:
|
||||
case D_QUIET:
|
||||
return;
|
||||
case D_NORMAL:
|
||||
case D_EDIT:
|
||||
|
||||
Reference in new issue
Block a user