# GIT-CVS sync script

3 messages from 2005-06-28 to 2005-06-28. Participants: Panagiotis Issaris, Matthias Urlichs, Linus Torvalds.
Thread: https://gitlist.dev/t/1037

## Panagiotis Issaris, 2005-06-28 19:14

Subject: GIT-CVS sync script
Message-ID: <20050628191445.GA27979@lumumba.uhasselt.be>
URL: https://gitlist.dev/e/20050628191445.GA27979%40lumumba.uhasselt.be

```
Hi,

I find the included script useful to easily track a CVS repository in
GIT. You can both call it for the initial import and ofcourse for the
subsequent resynchronisation with the parent CVS repository (that's what
the script's about).

Would it be better to provide this as a patch against git-cvsimport-script?

It has been tested on the RTAI-Fusion repository.

With friendly regards,
Takis

Signed-off-by: Panagiotis Issaris <takis@gna.org>

#!/usr/bin/env bash
#
# Keep a GIT repository in sync with a CVS repository.
# 
# Copyright (c) Panagiotis Issaris, 2005.
#

CVS2GIT_PATCHSETNR=.cvs2git_patchsetnr
CVS2GIT_UPGRADESCRIPT=.cvs2git_updatescript
PROJECT_GITDIR=`pwd`
PROJECT_CVSDIR=$1
CVSPS_OPTIONS="--no-rlog"

usage () {
        echo -e "Usage: \n\t$0 /path/to/project/cvsdir"
        exit 1
}

if test $# -lt 1 ; then
usage
else
if test ! -d $PROJECT_CVSDIR; then
usage
fi
fi

cd $PROJECT_CVSDIR

if test ! -d $PROJECT_GITDIR/.git; then

TZ=UTC cvsps $CVSPS_OPTIONS -A > $PROJECT_GITDIR/.git-cvsps-result
git-cvs2git --cvsroot=`cat CVS/Root` --module=`cat CVS/Repository` < $PROJECT_GITDIR/.git-cvsps-result > $PROJECT_GITDIR/.cvs2git_updatescript

else

if test -f $PROJECT_GITDIR/.cvs2git_patchsetnr; then
PATCHSETNR=`cat $PROJECT_GITDIR/.cvs2git_patchsetnr`;
else
PATCHSETNR=`cvsps | grep "^PatchSet " | tail -n1 | cut -f2 -d' '`
fi
let PATCHSETNR=$PATCHSETNR+1

# Updating from patchset $PATCHSETNR...
TZ=UTC cvsps $CVSPS_OPTIONS -x -s $PATCHSETNR- -A > $PROJECT_GITDIR/.git-cvsps-result
if test ! -s $PROJECT_GITDIR/.git-cvsps-result; then
echo "No new patchsets available"
exit 2
fi
git-cvs2git -u --cvsroot=`cat CVS/Root` --module=`cat CVS/Repository` < $PROJECT_GITDIR/.git-cvsps-result > $PROJECT_GITDIR/.cvs2git_updatescript

fi

# Storing last patchset number $PATCHSETNR
PATCHSETNR=`grep "^PatchSet " $PROJECT_GITDIR/.git-cvsps-result | tail -n1 | cut -f2 -d' '`
echo $PATCHSETNR > $PROJECT_GITDIR/.cvs2git_patchsetnr

# And finally, execute the generated script
cd $PROJECT_GITDIR
sh .cvs2git_updatescript

```

## Matthias Urlichs, 2005-06-28 19:33

Subject: Re: GIT-CVS sync script
Message-ID: <pan.2005.06.28.19.33.40.876796@smurf.noris.de>
URL: https://gitlist.dev/e/pan.2005.06.28.19.33.40.876796%40smurf.noris.de
In-Reply-To: <20050628191445.GA27979@lumumba.uhasselt.be>

```
Hi, Panagiotis Issaris wrote:

> I find the included script useful to easily track a CVS repository in
> GIT. You can both call it for the initial import and ofcourse for the
> subsequent resynchronisation with the parent CVS repository (that's what
> the script's about).
> 
Hmm, my Perl script (just posted...) should do the same thing without
depending on .git* files which may or may not still exist when you do an
incremental import half a year later.

Can you test whether that script works for you?

-- 
Matthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  smurf@smurf.noris.de
Disclaimer: The quote was selected randomly. Really. | http://smurf.noris.de
 - -
I may not be totally perfect, but parts of me are excellent.
		-- Ashleigh Brilliant

```

## Linus Torvalds, 2005-06-28 19:56

Subject: Re: GIT-CVS sync script
Message-ID: <Pine.LNX.4.58.0506281254040.19755@ppc970.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.58.0506281254040.19755%40ppc970.osdl.org
In-Reply-To: <pan.2005.06.28.19.33.40.876796@smurf.noris.de>

```


On Tue, 28 Jun 2005, Matthias Urlichs wrote:

> Hi, Panagiotis Issaris wrote:
> 
> > I find the included script useful to easily track a CVS repository in
> > GIT. You can both call it for the initial import and ofcourse for the
> > subsequent resynchronisation with the parent CVS repository (that's what
> > the script's about).
> > 
> Hmm, my Perl script (just posted...) should do the same thing without
> depending on .git* files which may or may not still exist when you do an
> incremental import half a year later.
> 
> Can you test whether that script works for you?

Please do. I'm not proud of my horrid cvs2git thing, and if just one other
user reports "it works for me" I'll happily replace that piece of cr*p
with Matthias' version that looks much nicer (but not being a perl user I
can't judge it any other way than having others say "yeah, that works for
me").

			Linus

```
