summaryrefslogtreecommitdiff
path: root/git2svn-sync
blob: dbb4fc4827392db26c4e429a3bc2cc189ce4586e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
#
# Sync git repository to subversion repository.
# 
# Based on http://google-opensource.blogspot.com/2008/05/export-git-project-to-google-code.html

if [ $# -lt 2 ] ; then
	echo "usage: ${0} GIT_REPO GIT_SVN_REPO_CHECKOUT"
	exit 2
fi

GIT_REPO=$1
GIT_SVN_REPO_CHECKOUT=$2

if [ ! -d $GIT_SVN_REPO_CHECKOUT/.git/svn ] ; then
	echo "error: no git-svn checkout found in $GIT_SVN_REPO_CHECKOUT"
	exit 3
fi

export GIT_DIR=$GIT_SVN_REPO_CHECKOUT
git fetch $GIT_REPO
git branch tmp $(cut -b-40 .git/FETCH_HEAD)
git tag -a -m "Last fetch" newlast tmp
git rebase --onto master last tmp
git branch -M tmp master
git svn dcommit
mv $GIT_SVN_REPO_CHECKOUT/.git/refs/newlast \
	$GIT_SVN_REPO_CHECKOUT/.git/refs/last

# vim:ft=sh