Skip to content

Instantly share code, notes, and snippets.

@afresh1
Created May 9, 2012 02:35
Show Gist options
  • Save afresh1/2641363 to your computer and use it in GitHub Desktop.
Save afresh1/2641363 to your computer and use it in GitHub Desktop.
OpenBSD CVS Port to openbsd-wip
#!/bin/sh
# https://gist.github.com/gists/2641363
# https://github.com/jasperla/openbsd-wip
# $ cd ~/openbsd-wip && CVSROOT=:local:/cvsroot import-cvs-to-git misc/anyport
#GITROOT=~/openbsd-wip
#GITROOT=/usr/ports/mystuff
GITROOT=`pwd`
CVSROOT=${CVSROOT:-/cvs}
# SUBDIR can be any valid dirname without trailing /
# causes subdirs to be imported. Leave unset to import to the root.
SUBDIR="TMPSUBDIR"
for MODULE in "$@"; do
MODULE=${MODULE:%/}
[ -n $SUBDIR -a -d ${GITROOT}/${MODULE} ] && continue
TMPDIR=`mktemp -d /tmp/cvsimport-XXXXXXX`
mkdir -p ${TMPDIR}/${SUBDIR}/`dirname ${MODULE}`
cp -r ${CVSROOT}/${MODULE} ${TMPDIR}/${SUBDIR}/${MODULE}
cd ${TMPDIR}
cvs -d ${TMPDIR} init
cd $GITROOT
git branch XbranchX
git checkout XbranchX
touch temp
git add temp
git commit -m "TEMP COMMIT" --date="1990-01-01 00:00:00"
temp_commit=`git log --format=format:%H -n1`
git cvsimport -d ${TMPDIR} -v -p -x -o XbranchX -k -u ${SUBDIR:-$MODULE}
git rebase --onto ${temp_commit}~1 ${temp_commit}
git checkout master
git merge XbranchX
git branch -d XbranchX
rm -rf ${TMPDIR}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment