Converting CVS repositories to Git

For convertig CVS repositories to Git I found a nice tool called crap (https://github.com/rcls/crap). However, if you need to convert a larger number of repositories it's better to automate the single commands with shell a script:

#!/bin/bash
cd  
for repo in `ls -1 cvsroot`; do  
  cd
  echo $repo
  mkdir ${repo}_from_cvs || (echo "ERROR: could not create directory" && continue)
  git init ${repo}_from_cvs || (echo "ERROR: could init repo" && continue)
  cd ${repo}_from_cvs/ || (echo "ERROR: could not enter directory" && continue)
  ~/crap/crap-clone ~/cvsroot ${repo}
done  

The CVS top level directory has to be ~/cvsroot. The crap directory has to be at ~/crap.

One single more complex and larger repository caused crap to segfault:

crap-clone[3543]: segfault at 20 ip 0000000000409344 sp 00007fffab3502c0 error 4 in crap-clone[400000+10000]  

I found another approach using cvs2git (http://cvs2svn.tigris.org/cvs2git.html):

cvs2git --blobfile=cvs2git-tmp/git-blob.dat --dumpfile=cvs2git-tmp/git-dump.dat --username=cvs2git --fallback-encoding=latin_1 cvsroot/REPO  
mkdir REPO_from_cvs  
cd REPO_from_cvs  
git init .  
git fast-import --export-marks=../cvs2git-tmp/git-marks.dat <../cvs2git-tmp/git-blob.dat  
git fast-import --import-marks=../cvs2git-tmp/git-marks.dat <../cvs2git-tmp/git-dump.dat  
git gc --prune=now