#!/bin/sh
# $Id: rcs2git,v 1.8 2016/06/10 08:11:26 tom Exp $
# vile:sw=4 ts=4

for name in "$@"
do
	if test -d "/tmp/$name.vcs"
	then
		NAME="/tmp/$name.vcs"
	elif test -d "/users/source/archives/$name.vcs"
	then
		NAME="/users/source/archives/$name.vcs"
	elif test -d "/usr/build/VCS/$name"
	then
		NAME="/usr/build/VCS/$name"
	else
		echo "...skip $name"
		continue
	fi

	cd /tmp
	rm -rf tmp.git
	mkdir tmp.git
	cd tmp.git
	git --bare init

	EXPORT_OPTS="--no-author-is-committer --skip-branches"
	case $NAME in
	pgf-vile)
		;;
	*)
		EXPORT_OPTS="--expand-keywords $EXPORT_OPTS"
		;;
	esac

	WHO=
	if test -f $HOME/com/$name-authors
	then
		WHO=$HOME/com/$name-authors
	elif test -f $HOME/.authors
	then
		WHO=$HOME/.authors
	fi
	test -n "$WHO" && EXPORT_OPTS="$EXPORT_OPTS --authors-file=$WHO"
	rcs-fast-export.rb $EXPORT_OPTS $NAME \
	|tee /tmp/export.out \
	|git fast-import --export-marks=/tmp/marks.data
	git bundle create ../$name.bundle --all
done
