diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-07-06 22:17:22 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-07-06 22:17:22 +0000 |
commit | 69ef970c20b54b2b30dab715b21100744a5e62a9 (patch) | |
tree | f2bf5f78372e7cbd33d673ccca85bd7ed0a8d67c /usr.bin | |
parent | a5f370d9b14b190b154fddc12987b9255cd20e10 (diff) |
Add -q option from GNU diff
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/diff/diff.1 | 15 | ||||
-rw-r--r-- | usr.bin/diff/diff.c | 20 | ||||
-rw-r--r-- | usr.bin/diff/diff.h | 3 | ||||
-rw-r--r-- | usr.bin/diff/diffdir.c | 8 | ||||
-rw-r--r-- | usr.bin/diff/diffreg.c | 8 |
5 files changed, 33 insertions, 21 deletions
diff --git a/usr.bin/diff/diff.1 b/usr.bin/diff/diff.1 index 4fb97ccb52b..feb5d67efb1 100644 --- a/usr.bin/diff/diff.1 +++ b/usr.bin/diff/diff.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: diff.1,v 1.12 2003/07/06 22:02:36 millert Exp $ +.\" $OpenBSD: diff.1,v 1.13 2003/07/06 22:17:21 millert Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -37,26 +37,26 @@ .Nd differential file and directory comparator .Sh SYNOPSIS .Nm diff -.Op Fl abitw +.Op Fl abiqtw .Oo .Fl c | Fl e | Fl f | .Fl n | Fl u .Oc .Ar file1 file2 .Nm diff -.Op Fl abitw +.Op Fl abiqtw .Op Fl C Ar number .Ar file1 file2 .Nm diff -.Op Fl abitw +.Op Fl abiqtw .Op Fl D Ar string .Ar file1 file2 .Nm diff -.Op Fl abitw +.Op Fl abiqtw .Op Fl U Ar number .Ar file1 file2 .Nm diff -.Op Fl abiNtw +.Op Fl abiNqtw .Oo .Fl c | Fl e | Fl f | .Fl n | Fl u @@ -129,6 +129,9 @@ but in the opposite order and with a count of changed lines on each insert or delete command. This is the form used by .Xr rcsdiff 1 . +.It Fl q +Just print a line when the files differ. +Does not output a list of changes. .It Fl u Produces a .Em unified diff --git a/usr.bin/diff/diff.c b/usr.bin/diff/diff.c index eaaf15c629e..afd54bdf271 100644 --- a/usr.bin/diff/diff.c +++ b/usr.bin/diff/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.24 2003/07/06 22:02:36 millert Exp $ */ +/* $OpenBSD: diff.c,v 1.25 2003/07/06 22:17:21 millert Exp $ */ /* * Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com> @@ -21,7 +21,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: diff.c,v 1.24 2003/07/06 22:02:36 millert Exp $"; +static const char rcsid[] = "$OpenBSD: diff.c,v 1.25 2003/07/06 22:17:21 millert Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -44,7 +44,7 @@ char *start, *ifdefname, *diffargs; struct stat stb1, stb2; struct excludes *excludes_list; -#define OPTIONS "abC:cD:efhinNPrS:stU:uwX:x:" +#define OPTIONS "abC:cD:efhinNPqrS:stU:uwX:x:" static struct option longopts[] = { { "text", no_argument, 0, 'a' }, { "ignore-space-change", no_argument, 0, 'b' }, @@ -56,6 +56,7 @@ static struct option longopts[] = { { "new-file", no_argument, 0, 'N' }, { "rcs", no_argument, 0, 'n' }, { "unidirectional-new-file", no_argument, 0, 'P' }, + { "brief", no_argument, 0, 'q' }, { "recursive", no_argument, 0, 'r' }, { "report-identical-files", no_argument, 0, 's' }, { "starting-file", required_argument, 0, 'S' }, @@ -128,6 +129,9 @@ main(int argc, char **argv) case 'r': rflag = 1; break; + case 'q': + format = D_BRIEF; + break; case 'S': start = optarg; break; @@ -314,11 +318,11 @@ __dead void usage(void) { (void)fprintf(stderr, - "usage: diff [-bitw] [-c | -e | -f | -n | -u ] file1 file2\n" - " diff [-bitw] -C number file1 file2\n" - " diff [-bitw] -D string file1 file2\n" - " diff [-bitw] -U number file1 file2\n" - " diff [-biNPwt] [-c | -e | -f | -n | -u ] [-r] [-s] [-S name]" + "usage: diff [-biqtw] [-c | -e | -f | -n | -u ] file1 file2\n" + " diff [-biqtw] -C number file1 file2\n" + " diff [-biqtw] -D string file1 file2\n" + " diff [-biqtw] -U number file1 file2\n" + " diff [-biNPqwt] [-c | -e | -f | -n | -u ] [-r] [-s] [-S name]" " [-X file]\n [-x pattern] dir1 dir2\n"); exit(2); diff --git a/usr.bin/diff/diff.h b/usr.bin/diff/diff.h index 0264115269d..a2f63cc8d48 100644 --- a/usr.bin/diff/diff.h +++ b/usr.bin/diff/diff.h @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.h,v 1.16 2003/07/06 22:02:36 millert Exp $ */ +/* $OpenBSD: diff.h,v 1.17 2003/07/06 22:17:21 millert Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -42,6 +42,7 @@ #define D_IFDEF 4 /* Diff with merged #ifdef's */ #define D_NREVERSE 5 /* Reverse ed script with numbered lines and no trailing . */ +#define D_BRIEF 6 /* Say if the files differ */ /* * Output flags diff --git a/usr.bin/diff/diffdir.c b/usr.bin/diff/diffdir.c index 659d0346a73..0907e3bc86a 100644 --- a/usr.bin/diff/diffdir.c +++ b/usr.bin/diff/diffdir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diffdir.c,v 1.20 2003/07/06 22:02:36 millert Exp $ */ +/* $OpenBSD: diffdir.c,v 1.21 2003/07/06 22:17:21 millert Exp $ */ /* * Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com> @@ -21,7 +21,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: diffdir.c,v 1.20 2003/07/06 22:02:36 millert Exp $"; +static const char rcsid[] = "$OpenBSD: diffdir.c,v 1.21 2003/07/06 22:17:21 millert Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -114,7 +114,7 @@ diffdir(char *p1, char *p2) if (Nflag) diffit(dent1, path1, dirlen1, path2, dirlen2); else if (format == D_NORMAL || format == D_CONTEXT || - format == D_UNIFIED) + format == D_UNIFIED || format == D_BRIEF) /* XXX GNU diff always prints this XXX */ printf("Only in %.*s: %s\n", (int)(dirlen1 - 1), path1, dent1->d_name); @@ -124,7 +124,7 @@ diffdir(char *p1, char *p2) if (Nflag || Pflag) diffit(dent2, path1, dirlen1, path2, dirlen2); else if (format == D_NORMAL || format == D_CONTEXT || - format == D_UNIFIED) + format == D_UNIFIED || format == D_BRIEF) /* XXX GNU diff always prints this XXX */ printf("Only in %.*s: %s\n", (int)(dirlen2 - 1), path2, dent2->d_name); diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index 3a5852125e5..4e15c6b8ac1 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diffreg.c,v 1.27 2003/07/06 20:48:59 millert Exp $ */ +/* $OpenBSD: diffreg.c,v 1.28 2003/07/06 22:17:21 millert Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -65,7 +65,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.27 2003/07/06 20:48:59 millert Exp $"; +static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.28 2003/07/06 22:17:21 millert Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -340,6 +340,10 @@ notsame: * Files certainly differ at this point; set status accordingly */ status |= 1; + if (format == D_BRIEF) { + printf("Files %s and %s differ\n", file1, file2); + goto closem; + } if (flags & D_HEADER) { if (format == D_EDIT) printf("ed - %s << '-*-END-*-'\n", basename(file1)); |