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 &&