Nat! bio photo

Nat!

Senior Mull

Twitter Github Twitch

Importing CVS into git on Mac OS X

It's pretty simple, but you need to set some git config variables to make the import go smoothly.

First up, you need cvsps. The currently stable cvsps version 2.1 works better with the git version 1.7.4.4, that Xcode gave me, so download it.

Building cvsps is just make and installing into /usr/local is just sudo make install

Then get your CVSROOT environment variable set properly.

Finally you need to configure some variables in git, as they may be set to values, that preclude a working import. Here 's a shell script, which isn't foolproof, but useful enough.

#! /bin/sh

rm -rf .git

#
# my settings
# core.autocrlf=input
# core.safecrlf=true
#

old_autocrlf=`git config --get core.autocrlf`
old_safecrlf=`git config --get core.safecrlf`
old_encoding=`git config --get i18n.commitencoding`

git config --global core.autocrlf  false
git config --global core.safecrlf  false
git config --global i18n.commitencoding MacRoman

git cvsimport $*

if [ "$old_autocrlf" != "" ]
then
   git config --global core.autocrlf "$old_autocrlf"
else
   git config --global --unset core.autocrlf
fi

if [ "$old_safecrlf" != "" ]
then
   git config --global core.safecrlf "$old_safecrlf"
else
   git config --global --unset core.safecrlf
fi

if [ "$old_encoding" != "" ]
then
   git config --global i18n.commitencoding "$old_encoding"
else
   git config --global --unset i18n.commitencoding
fi