Next: , Previous: Log Messages And Commit Emails, Up: Advanced CVS


Changing A Log Message After Commit

Just in case someone does commit a regrettable log message, CVS enables you to rewrite logs after they've been committed. It's done with the -m option to the admin command (this command is covered in more detail later in this chapter) and allows you to change one log message (per revision, per file) at a time. Here's how it works:

     floss$ cvs admin -m 1.7:"Truncate four-digit years to two in input." date.c
     RCS file: /usr/local/newrepos/someproj/date.c,v
     done
     floss$

The original, offensive log message that was committed with revision 1.7 has been replaced with a perfectly innocent – albeit duller – message. Don't forget the colon separating the revision number from the new log message.

If the new log message consists of multiple lines, put it in a file and do this:

     floss$ cvs admin -m 1.7:"`cat new-log-message.txt`" date.c

(This example was sent in by Peter Ross <peter.ross@miscrit.be>; note that it only works for Unix users.)

If the bad message was committed into multiple files, you'll have to run cvs admin separately for each one, because the revision number is different for each file. Therefore, this is one of the few commands in CVS that requires you to pass a single file name as argument:

     floss$ cvs admin -m 1.2:"very boring log message" hello.c README.txt foo.gif
     cvs admin: while processing more than one file:
     cvs [admin aborted]: attempt to specify a numeric revision
     floss$

Confusingly, you get the same error if you pass no file names (because CVS then assumes all the files in the current directory and below are implied arguments):

     floss$ cvs admin -m 1.2:"very boring log message"
     cvs admin: while processing more than one file:
     cvs [admin aborted]: attempt to specify a numeric revision
     floss$

(As is unfortunately often the case with CVS error messages, you have to see things from CVS's point of view before the message makes sense!)

Invoking admin -m actually changes the project's history, so use it with care. There will be no record that the log message was ever changed – it will simply appear as if that revision had been originally committed with the new log message. No trace of the old message will be left anywhere (unless you saved the original commit email).

Although its name might seem to imply that only the designated CVS administrator can use it, in fact anyone can run cvs admin, as long as they have write access to the project in question. Nevertheless, it is best used with caution; the ability to change log messages is mild compared with other potentially damaging things it can do. See CVS Reference for more about admin, as well as a way to restrict its use.

Karl Fogel wrote this book. Buy a printed copy via his homepage at red-bean.com

copyright  ©  September 17 2019 sean dreilinger url: https://durak.org/sean/pubs/software/cvsbook/Changing-A-Log-Message-After-Commit.html