]> git.phdru.name Git - git-scripts.git/blob - svn/clone
8e880c3aa5bd6d4cd86c4915baf5706894e7692b
[git-scripts.git] / svn / clone
1 #! /bin/sh
2
3 if [ -z "$1" ]; then
4    echo "Usage: $0 svn_url [dir]" >&2
5    exit 1
6 fi
7
8 url="$1"
9
10 if [ ! -f authors.txt ]; then
11    echo "Run \"get-authors $1\" first" >&2
12    exit 2
13 fi
14
15 if [ -z "$2" ]; then
16    dir="`basename $url`"
17 else
18    dir="$2"
19 fi
20
21 if [ -z "$dir" ]; then
22    echo "Usage: $0 $url dir" >&2
23    exit 1
24 fi
25
26 # init + fetch
27 git svn clone "$url" --authors-file=authors.txt --stdlayout "$dir" &&
28 cd "$dir" &&
29
30 # fix references
31 #cp -rf .git/refs/remotes/tags/* .git/refs/tags/ &&
32 #rm -rf .git/refs/remotes/tags
33 #cp -rf .git/refs/remotes/* .git/refs/heads/ &&
34 #rm -rf .git/refs/remotes
35
36 # convert svn:ignore to .gitignore
37 git svn create-ignore &&
38 git commit -m "Add .gitignore"
39
40 # preserve authors.txt
41 cp -p ../authors.txt .git/info &&
42 git config --local --path svn.authorsfile .git/info/authors.txt
43
44 git svn gc &&
45 git gc --aggressive &&
46 echo "Cloned from $url using git-svn" >.git/description &&
47 exec "${VISUAL:-${EDITOR:-vi}}" .git/description