cvs2git Documentation

# cvs2git

## Index

- Introduction
- Requirements
- Development status
- Documentation
- Usage

## Introduction

cvs2svn/cvs2git is a tool that can be used to migrate CVS repositories to newer version control tools, including git. git is a distributed version control system most famous for being used for Linux kernel development. The program used to convert to git, called cvs2git, is distributed as part of the cvs2svn project.

If you are reading this documentation on the cvs2svn website, then please be aware that it describes the current trunk version of cvs2svn, which may be different than the most recent released version. Please refer to the documentation that was included with your version of cvs2svn.

Conversion to git was added in release 2.1 of cvs2svn and has improved significantly since then. Please make sure you are using an up-to-date version of cvs2svn--perhaps even the development trunk version.

## Requirements

cvs2git requires the following:

- Direct (filesystem) access to a copy of the CVS repository that you want to convert. cvs2git parses the files in the CVS repository directly, so it is not enough to have remote CVS access. See the FAQ for more information and a possible workaround.
- Python 2, version 2.4 or later. See http://www.python.org/. (cvs2git does not work with Python 3.x.)
- If you use the `--use-rcs` option, then RCS's `co' program is required. The RCS home page is http://www.cs.purdue.edu/homes/trinkle/RCS/. See the `--use-rcs` flag for more details.
- If you use the `--use-cvs` option, then the `cvs' command is required. The CVS home page is http://ccvs.cvshome.org/. See the `--use-cvs` flag for more details.
- GNU sort, which is part of the coreutils package, see http://www.gnu.org/software/coreutils/. Binaries for Win32 can be found at http://unxutils.sourceforge.net/. Windows `sort.exe` is not adequate.
- Git version 1.5.4.4 or later (earlier versions have a bug in "git fast-import" that prevent them from loading the files generated by cvs2git).

## Development status

Most of the work of converting a repository from CVS to a more modern version control system is inferring the most likely history given the incomplete information that CVS records. cvs2svn has a long history of making sense of even the most convoluted CVS repositories, and cvs2git uses this same machinery. Therefore, cvs2git inherits the robustness and many of the features of cvs2svn. cvs2svn can convert just about every CVS repository we have ever seen, and includes a plethora of options for customizing your conversion.

The output of cvs2git is one or more dump files that can be imported into git using the excellent git fast-import tool.

Although cvs2git is considerably newer than cvs2svn, and much less well tested, it is believed that cvs2git can (cautiously) be used for production conversions. If you use cvs2git, please let us know how it worked for you!

## cvs2git limitations

cvs2git still has many limitations compared to cvs2svn. The main cvs2svn developer has limited git experience and very limited time, so help would be much appreciated! Some of these missing features would be pretty easy to program, and I'd be happy to help you get started.

- The cvs2git documentation is still rather thin. See below for more references.
- CVS allows a branch to be created from arbitrary combinations of source revisions and/or source branches. cvs2git tries to create a branch from a single source, but if it can't figure out how to, it creates the branch using "merge" from multiple sources. In pathological situations, the number of merge sources for a branch can be arbitrarily large.
- If cvs2git cannot determine that a CVS tag can be created from a single revision, then it creates a tag fixup branch named `TAG.FIXUP`, then tags this branch. (This is a necessary workaround for the fact that CVS tags are fundamentally different than git tags.) The `TAG.FIXUP` branch is cleared at the end of the conversion, but not deleted. There are some situations when a tag could be created from a single revision, but cvs2git does not realize it and creates a superfluous tag fixup branch. It is possible to delete all superfluous tag fixup branches after the conversion, by running the `contrib/git-move-tags.py` script within the resulting git repository.
- There are no checks that CVS branch and tag names are legal git names. There are probably other git constraints that should also be checked.
- The data that should be fed to git fast-import are written to two files, which have to be loaded into git fast-import manually. These files might grow to very large size. It would be nice to add an option to invoke git fast-import automatically and pipe the output directly into git fast-import; this should also speed up the conversion.
- Only single projects can be converted at a time. Given the way git is typically used, I don't think that this is a significant limitation.
- cvs2git is not especially fast. Among other things, it still uses RCS or CVS to extract the contents of the CVS revisions. Implementing the `--internal-co` option for cvs2git (using code that already exists in cvs2svn) might improve the conversion speed considerably.
- The cvs2svn test suite does not include meaningful tests of git output.
- cvs2git makes no attempt to convert `.cvsignore` files into `.gitignore` files.
- cvs2git, like cvs2svn, does not support incremental conversion (i.e., tracking a live CVS repository). However, at least one person has documented a possible workaround.

## Documentation

There is some documentation specific to cvs2git, and much of the cvs2svn documentation also applies fairly straightforwardly to cvs2git. See the following sources:

- This document.
- The cvs2git man page and the output of `cvs2git --help`.
- The cvs2svn documentation and the cvs2svn FAQ, which contain much general discussion and describe many features that can also be used for cvs2git.
- `cvs2git-example.options` in the cvs2svn source tree, which is an example of an options file that can be used to configure a cvs2git conversion. The file is extensively documented.
- The cvs2svn mailing lists, IRC channel, etc., as described in the cvs2svn FAQ.

## Usage

This section outlines the steps needed to convert a CVS repository to git using cvs2git.

1. Be sure that you have the requirements, including either RCS or CVS (used to read revision contents from the CVS repository).
2. Obtain a copy of cvs2svn/cvs2git version 2.1 or newer. It is recommended that you use the most recent version available, or even the development version.
   - To install cvs2svn from a tarball, simply unpack the tarball into a directory on your conversion computer (cvs2git can be run directly from this directory).

   - To check out the current trunk version of cvs2svn, make sure that you have Subversion installed and then run:

         svn co --username=guest http://cvs2svn.tigris.org/svn/cvs2svn/trunk cvs2svn-trunk
         # The password is empty; i.e., just press return.
         cd cvs2svn-trunk
         make man # If you want to create manpages for the main programs
         make check # ...optional

     Please note that the test suite includes tests that are marked "XFAIL" (expected failure); these are known and are not considered serious problems.

3. Configure cvs2git for your conversion. This can be done via command-line options or via an options file:
   - The command-line options for running cvs2git are documented in the cvs2git man page and in the output of `cvs2git --help`.

   - The more flexible options-file method requires you to create an options file, then start cvs2git with

         cvs2git --options=OPTIONS-FILE

     Use `cvs2git-example.options` in the cvs2svn source tree as your starting point; the file contains lots of documentation.

4. Run cvs2git. This creates two output files in git fast-import format. The names of these files are specified by your options file or command-line arguments. In the example, these files are named `cvs2svn-tmp/git-blob.dat` and `cvs2svn-tmp/git-dump.dat`.

5. Initialize a git repository, and load the dump files using git fast-import:

       git init
       cat cvs2svn-tmp/git-blob.dat | git fast-import --export-marks=cvs2svn-tmp/git-marks.dat
       cat cvs2svn-tmp/git-dump.dat | git fast-import --import-marks=cvs2svn-tmp/git-marks.dat

   This can, of course, be shortened to:

       git init
       cat cvs2svn-tmp/git-blob.dat cvs2svn-tmp/git-dump.dat | git fast-import

6. If you want to get rid of unnecessary tag fixup branches, then run the `contrib/git-move-tags.py` script from within the git repository.

Feedback would be much appreciated, including reports of success using cvs2git. Please send comments, bug reports, and patches to the cvs2svn mailing lists.