How to use git cvs frontend

As my company is still using CVS as a software revision control system, and as I am used to Git and cannot work without it, i had to deal with the git-cvs front end. I have to say that it is not so easy to use it, because there is not a lot of maintainers, and also a lack of users. So i had to made some scripts to get it to work in an automatic way.

In this tutorial, the following prerequisites are expected:

  • You have Git installed,
  • You have CVS installed,
  • You have cvsps installed,
  • You have an existing CVS repository,
  • You defined the environment variable CVSROOT correctly and already logged in to CVS with “cvs login”,
  • You defined the environment variable CVSMODULE with the name of your CVS module you want to import into Git,
  • You defined the environment variable WORKDIR with the name of your working directory (ie where you want the repository),
  • You have basic knowledges about Git and CVS (ie you know and understand how to do following operations: checkout, commit, update).

First step was to import an existing CVS repository into Git, and that was the easiest step, but not the shortest (if you have a big history in your CVS tree, it will take hours to import it):

# first checkout the CVS tree
cvs -d "${CVSROOT}" checkout -kk -d "${WORKDIR}" -P "${CVSMODULE}"
# change directory to the checked out CVS module
cd "${WORKDIR}"
# import CVS history into new Git repository (this will take a long time depending on your CVS history size)
# Options explanation:
# * -p tells git to pass following options to cvsps:
#    – -x force cvsps to discard his cache,
#    – -q tells cvsps to be quiet,
#    – –no-cvs-direct tells cvsps to not use it’s own
#    implementation of CVS protocol, avoiding unnecessary
#    warnings when CVS server is too old,
#    – –no-rlog tells cvsps to not use the rlog CVS command,
#    which is not supported by all CVS servers versions,
# * -k tells git to not perform keywords substitution when importing,
# * -d indicates the CVSROOT to checkout the module from,
# * -r cvs indicates that CVS tree should be imported in remote cvs,
# * -a tells git to import recent CVS commits,
git cvsimport -p -x,-q,–no-cvs-direct,–no-rlog \
-k -d "${CVSROOT}" -r cvs -a "${CVSMODULE}"

At this point, you can do whatever you want in your git repository. I recommend you to checkout another branch using git checkout -b “branch name”, before doing any modifications in the git tree. This will save up time when trying to update from CVS or export your modifications to CVS.

When you will want to import modifications from the CVS repository, I wrote a little script that checks each prerequisite to do so and realize the import for you. You can find this script here. To use it:

cvsimport.sh "${WORKDIR}" "${CVSROOT}" "${CVSMODULE}"

When you will want to export your modifications to the Git repository, I also wrote a script for that. This script will be uploaded soon. To use it:

cvsexport.sh "${WORKDIR}" "${CVSROOT}" "${CVSMODULE}"

To use theses scripts, you need first to have a clean Git working directory, meaning that all your modifications should either be committed on your branch, or stashed.

I hope this post has been helpful for you, and feel free to post any comments about amelioration I can bring to it.

Leave a Comment