More information on files: what changed and why

The revision number is 1.2 instead of 1.1. We now have two separate revisions of foo.c, so now we can see what changed between them and why the changes were made.

To find out why, we need to look at the log messages that were entered every time a commit was performed:

cvs log foo.c

RCS file: /home/fred/cvs/myproj/foo.c,v
Working file: foo.c
head: 1.2
branch:
locks: strict
access list:
keyword substitution: kv
total revisions: 2;     selected revisions: 2
description:
----------------------------
revision 1.2
date: 2003/06/03 17:35:43;  author: fred;  state: Exp;  lines: +2 -0
Added comments for clarity.
----------------------------
revision 1.1
date: 2003/06/03 17:19:34;  author: fred;  state: Exp;
A file to test the basic functionality of CVS
===================================================================

To see what changed between the two revisions, use the diff command:

cvs diff -r1.1 foo.c

Index: foo.c
===================================================================
RCS file: /home/fred/cvs/myproj/foo.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -r1.1 -r1.2
0a1,2
> /* This is a file to test cvs */
>

The last lines, starting with diff -r1.1 -r1.2z, show the actual differences using the standard diff format (see the Utilities Reference).

You may have noticed that in the diff command above, we specified only one revision, by using the -r option. CVS assumes the second revision is the same as that of foo.c in your sandbox. We saw from the last status command that the working revision was 1.2, so that's the second revision. We could have defined the revision explicitly instead by using a second -r option:

cvs diff -r1.1 -r1.2 foo.c

Index: foo.c
===================================================================
RCS file: /home/fred/cvs/myproj/foo.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -r1.1 -r1.2
0a1,2
> /* This is a file to test cvs */
>

The results are exactly the same.