summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
authorJean-Francois Brousseau <jfb@cvs.openbsd.org>2005-04-25 19:09:16 +0000
committerJean-Francois Brousseau <jfb@cvs.openbsd.org>2005-04-25 19:09:16 +0000
commit82d0504cfbb8840ac58acf9708c557f60e4ffe83 (patch)
tree36e94ffde02d0174c1fdc7b1b9dc14d4f60888bc /usr.bin/cvs
parent2bf3bc5ff034c8ac6a54e2d99ddf59e2ba8f3756 (diff)
resurrect missing parts to generate rcsdiff(1)-style diffs with the -n
flag ok xsa
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/cvs.18
-rw-r--r--usr.bin/cvs/cvs.c6
-rw-r--r--usr.bin/cvs/diff.c23
3 files changed, 30 insertions, 7 deletions
diff --git a/usr.bin/cvs/cvs.1 b/usr.bin/cvs/cvs.1
index 6ea498dc09b..c8544f2422e 100644
--- a/usr.bin/cvs/cvs.1
+++ b/usr.bin/cvs/cvs.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: cvs.1,v 1.62 2005/04/12 20:18:55 xsa Exp $
+.\" $OpenBSD: cvs.1,v 1.63 2005/04/25 19:09:15 jfb Exp $
.\"
.\" Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
.\" Copyright (c) 2004, 2005 Xavier Santolaria <xsa@openbsd.org>
@@ -549,7 +549,7 @@ Aliases:
.Ic ci ,
.Ic com .
.It Xo Ic diff
-.Op Fl cilNpRu
+.Op Fl cilNnpRu
.Oo Oo Fl D
.Ar date1 \*(Ba
.Fl r Ar rev1 Oc
@@ -598,6 +598,10 @@ Limit the scope of the search to the local directory
only and disable recursive behaviour.
.It Fl N
Include added or removed files.
+.It Fl n
+Produces a diff in the same format as that used by
+.Xr rcsdiff 1 ,
+with a count of changed lines on each insert or delete command.
.It Fl p
With unified and context diffs, show with each change the first
40 characters of the last line before the context beginning with
diff --git a/usr.bin/cvs/cvs.c b/usr.bin/cvs/cvs.c
index 9b9edf26404..6e88ef34b74 100644
--- a/usr.bin/cvs/cvs.c
+++ b/usr.bin/cvs/cvs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.c,v 1.60 2005/04/25 17:59:16 jfb Exp $ */
+/* $OpenBSD: cvs.c,v 1.61 2005/04/25 19:09:15 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -123,8 +123,8 @@ struct cvs_cmd cvs_cdt[] = {
},
{
CVS_OP_DIFF, "diff", { "di", "dif" }, &cvs_diff,
- "[-cilNpRu] [-D date] [-r rev] ...",
- "cD:ilNpRr:u",
+ "[-cilNnpRu] [-D date] [-r rev] ...",
+ "cD:ilNnpRr:u",
"Show differences between revisions",
NULL
},
diff --git a/usr.bin/cvs/diff.c b/usr.bin/cvs/diff.c
index 046e93d08a6..29f013c0c3b 100644
--- a/usr.bin/cvs/diff.c
+++ b/usr.bin/cvs/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.32 2005/04/22 03:38:56 joris Exp $ */
+/* $OpenBSD: diff.c,v 1.33 2005/04/25 19:09:15 jfb Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@@ -130,6 +130,7 @@
#include <sys/stat.h>
#include <sys/wait.h>
+#include <err.h>
#include <errno.h>
#include <ctype.h>
#include <stdio.h>
@@ -159,6 +160,7 @@
#define D_UNIFIED 2 /* Unified context diff */
#define D_IFDEF 3 /* Diff with merged #ifdef's */
#define D_BRIEF 4 /* Say if the files differ */
+#define D_RCSDIFF 5 /* Reverse editor output: RCS format */
/*
* Status values for print_status() and diffreg() return values
@@ -392,6 +394,10 @@ cvs_diff_options(char *opt, int argc, char **argv, int *arg)
strlcat(diffargs, " -N", sizeof(diffargs));
Nflag = 1;
break;
+ case 'n':
+ strlcat(diffargs, " -n", sizeof(diffargs));
+ format = D_RCSDIFF;
+ break;
case 'p':
strlcat(diffargs, " -p", sizeof(diffargs));
pflag = 1;
@@ -1332,6 +1338,16 @@ proceed:
range(c, d, ",");
putchar('\n');
break;
+ case D_RCSDIFF:
+ if (a > b)
+ printf("a%d %d\n", b, d - c + 1);
+ else {
+ printf("d%d %d\n", a, b - a + 1);
+
+ if (!(c > d)) /* add changed lines */
+ printf("a%d %d\n", b, d - c + 1);
+ }
+ break;
}
if (format == D_NORMAL || format == D_IFDEF) {
fetch(ixold, a, b, f1, '<', 1);
@@ -1389,7 +1405,10 @@ fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile)
col = 0;
for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) {
if ((c = getc(lb)) == EOF) {
- puts("\n\\ No newline at end of file");
+ if (format == D_RCSDIFF)
+ warnx("No newline at end of file");
+ else
+ puts("\n\\ No newline at end of file");
return (0);
}
if (c == '\t' && tflag) {