1

I want to see exactly what will be committed before I run a cvs commit command. I just recently added a file using

cvs add myFile

and then committed the file using

cvs commit -m "my message"

but when I ran the commit command, I ended up modifying other files as well as removing files that I did not intend to change or had no idea were going to be committed and so I had to revert these files back one by one. I believe it is called the staging area? Where files that are added but haven't been committed yet or ready to be commited? I just want to see what changes will be made before I actually run the cvs commit command.

CodeRich
  • 157

3 Answers3

1

I have not used cvs for a long while: sub-version svn and mercurial hg are better. They have atomic commits (every file is committed together, so you can role-back the whole commit in one step).

Specify the file to commit: cvs commit -m '«message»' '«file-names…»'

#↳ cvs --help commit
Usage: cvs commit [-cRlf] [-m msg | -F logfile] [-r rev] files...

And/or use cvs status to find the information that you are looking for.

The cvs status command is a quick way to determine which files are up-to-date and which need to be committed or merged. ... — https://www.oreilly.com/library/view/essential-cvs/0596004591/ch03s04.html#:~:text=The%20cvs%20status%20command%20is,merged.

0

You can use the update command to show modified and added files that will be committed if you don't specify which files to commit. Add option -n to simulate the update (dry-run), e.g.

$ cvs -n up
cvs update: Updating .
M foo
A yum

shows file yum as added and file foo as modified (up is an alias for update, see cvs --help-synonyms).

Freddy
  • 25,565
  • Curious why this had a down-vote. This works fine for me. Produces comparably useful output IMO to the cvs status piped to grep method I showed. And this is faster. I tested on a folder with ~640 CVS files and the cvs update method took about 3 seconds to run compared to ~15s for cvs status. – SSilk Nov 06 '23 at 08:21
0

Since the OP is specifically interested in what changes will be committed, and cvs status could be very long if there are many files in the current directory,

cvs status | grep -P 'Status: (?!Up-to-date)'

can be used to show only files that are not already under revision control and up to date. This may still have some extraneous info like files that are not yet checked in and are not staged for commit (i.e. files CVS knows nothing about). But should be less to wade through. This assumes a version of grep that supports the -P "Perl style regex" option.

Note that Freddy's method provides similar output and is much faster.

SSilk
  • 153