X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=svn%2Fclone;h=b225f69e6ff3c7ce03997d523297b84ccd9e2b43;hb=27836ac622d1e6642f98eba6d5f34c4e9dcd18cc;hp=c206fc2800d942bccb12369aea13a9f2d6add153;hpb=1d8eeb5de7c1b6b7c58d36cb1b5d9618aa6e98f7;p=git-scripts.git diff --git a/svn/clone b/svn/clone index c206fc2..b225f69 100755 --- a/svn/clone +++ b/svn/clone @@ -24,18 +24,31 @@ 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 && -git commit -m "Add .gitignore" && +git commit -m "Add .gitignore" # preserve authors.txt cp -p ../authors.txt .git/info &&