CVS diff with new files: fakeadd

published on October 30, 2007

Ever been disgruntled by the fact that you can’t do a cvs diff with new files, because you haven’t got write access on a Drupal contrib module’s CVS repository and thus can’t cvs add those new files? There’s a solution though: edit CVS’s Entries file. But who likes manually modifying files over and over again?

The solution: fakeadd! (I’ve attached the file to this post in case this site ever goes down.) This nice shellscript allows you to update the Entries file using a simple syntax: fakeadd newfile.php.

A quick install how-to:

  1. Save the file to a location of your choice, I’ve saved it in ~/scripts.
  2. Open your ~/.bash_profile file (if you’re using the bash shell, this is the default shell on OS X) and add the following:

    # Add custom scripts, such as the CVS fakeadd script.
    export PATH=$PATH:~/scripts` 
    
  3. Make the script executable: chmod +x ~/scripts/fakeadd.

  4. When you create patches (also see this blog post of mine), use the -N flag. So your eventual command will look like this: cvs diff -N -up > foo.patch.

Update on November 30, 2008

The above blog post was improved based on the feedback I got in the comments: * Robert Douglass mentioned in the comments that you have to pass the -N parameter for cvs diff to pick up new files. * drewish was kind enough to post an improved version in the comments, which allows you to use the script for files in subdirectories.