From f5765a0a713b7b9d8f1e3e24577e08ab2d49b0ed Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 10 Jul 2014 08:03:29 +0400 Subject: [PATCH] Convert tags and branches --- svn/clone | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/svn/clone b/svn/clone index 8e880c3..b225f69 100755 --- a/svn/clone +++ b/svn/clone @@ -24,14 +24,27 @@ if [ -z "$dir" ]; then fi # init + fetch -git svn clone "$url" --authors-file=authors.txt --stdlayout "$dir" && +git svn clone "$url" --authors-file=authors.txt --prefix=svn/ --stdlayout "$dir" && cd "$dir" && -# fix references -#cp -rf .git/refs/remotes/tags/* .git/refs/tags/ && -#rm -rf .git/refs/remotes/tags -#cp -rf .git/refs/remotes/* .git/refs/heads/ && -#rm -rf .git/refs/remotes +# Convert tags and branches + +# See http://blog.jessitron.com/2013/08/converting-from-svn-to-git.html + +git for-each-ref --format="%(refname:short)" refs/remotes/svn | + sed 's#svn/##' | grep -v '^tags' | + while read aBranch; do git branch $aBranch svn/$aBranch || exit 1; done + +# See http://thomasrast.ch/git/git-svn-conversion.html + +git for-each-ref --format="%(refname:short)" refs/remotes/svn/tags/ | +while read tag; do + GIT_COMMITTER_DATE="`git log -1 --pretty=format:\"%ad\" \"$tag\"`" \ + GIT_COMMITTER_EMAIL="`git log -1 --pretty=format:\"%ce\" \"$tag\"`" \ + GIT_COMMITTER_NAME="`git log -1 --pretty=format:\"%cn\" \"$tag\"`" \ + git tag -a -m "`git for-each-ref --format=\"%(contents)\" \"$tag\"`" \ + "`echo \"$tag\" | sed 's#svn/tags/##'`" "$tag" || exit 1 +done # convert svn:ignore to .gitignore git svn create-ignore && -- 2.39.2