]>
Commit | Line | Data |
---|---|---|
706587fc EW |
1 | #!/bin/sh |
2 | # Copyright (c) 2006 Eric Wong | |
3 | test_description='git-svn metadata migrations from previous versions' | |
4 | . ./lib-git-svn.sh | |
5 | ||
f69e836f BD |
6 | test_expect_success 'setup old-looking metadata' ' |
7 | cp "$GIT_DIR"/config "$GIT_DIR"/config-old-git-svn && | |
97f6987a | 8 | mkdir import && |
4bb9ed04 | 9 | cd import && |
97f6987a EW |
10 | for i in trunk branches/a branches/b \ |
11 | tags/0.1 tags/0.2 tags/0.3; do | |
f69e836f BD |
12 | mkdir -p $i && \ |
13 | echo hello >> $i/README || exit 1 | |
97f6987a | 14 | done && \ |
f69e836f | 15 | svn import -m test . "$svnrepo" |
97f6987a | 16 | cd .. && |
f69e836f | 17 | git-svn init "$svnrepo" && |
706587fc | 18 | git-svn fetch && |
f69e836f BD |
19 | mv "$GIT_DIR"/svn/* "$GIT_DIR"/ && |
20 | mv "$GIT_DIR"/svn/.metadata "$GIT_DIR"/ && | |
21 | rmdir "$GIT_DIR"/svn && | |
5be60078 JH |
22 | git update-ref refs/heads/git-svn-HEAD refs/remotes/git-svn && |
23 | git update-ref refs/heads/svn-HEAD refs/remotes/git-svn && | |
24 | git update-ref -d refs/remotes/git-svn refs/remotes/git-svn | |
f69e836f | 25 | ' |
706587fc EW |
26 | |
27 | head=`git rev-parse --verify refs/heads/git-svn-HEAD^0` | |
28 | test_expect_success 'git-svn-HEAD is a real HEAD' "test -n '$head'" | |
29 | ||
f69e836f BD |
30 | test_expect_success 'initialize old-style (v0) git-svn layout' ' |
31 | mkdir -p "$GIT_DIR"/git-svn/info "$GIT_DIR"/svn/info && | |
32 | echo "$svnrepo" > "$GIT_DIR"/git-svn/info/url && | |
33 | echo "$svnrepo" > "$GIT_DIR"/svn/info/url && | |
706587fc | 34 | git-svn migrate && |
f69e836f | 35 | ! test -d "$GIT_DIR"/git-svn && |
5be60078 JH |
36 | git rev-parse --verify refs/remotes/git-svn^0 && |
37 | git rev-parse --verify refs/remotes/svn^0 && | |
f69e836f BD |
38 | test "$(git config --get svn-remote.svn.url)" = "$svnrepo" && |
39 | test `git config --get svn-remote.svn.fetch` = \ | |
40 | ":refs/remotes/git-svn" | |
41 | ' | |
706587fc | 42 | |
f69e836f BD |
43 | test_expect_success 'initialize a multi-repository repo' ' |
44 | git-svn init "$svnrepo" -T trunk -t tags -b branches && | |
5be60078 | 45 | git config --get-all svn-remote.svn.fetch > fetch.out && |
f69e836f BD |
46 | grep "^trunk:refs/remotes/trunk$" fetch.out && |
47 | test -n "`git config --get svn-remote.svn.branches \ | |
48 | "^branches/\*:refs/remotes/\*$"`" && | |
49 | test -n "`git config --get svn-remote.svn.tags \ | |
50 | "^tags/\*:refs/remotes/tags/\*$"`" && | |
4bb9ed04 | 51 | git config --unset svn-remote.svn.branches \ |
f69e836f | 52 | "^branches/\*:refs/remotes/\*$" && |
4bb9ed04 | 53 | git config --unset svn-remote.svn.tags \ |
f69e836f BD |
54 | "^tags/\*:refs/remotes/tags/\*$" && |
55 | git config --add svn-remote.svn.fetch "branches/a:refs/remotes/a" && | |
56 | git config --add svn-remote.svn.fetch "branches/b:refs/remotes/b" && | |
4bb9ed04 | 57 | for i in tags/0.1 tags/0.2 tags/0.3; do |
5be60078 | 58 | git config --add svn-remote.svn.fetch \ |
f69e836f BD |
59 | $i:refs/remotes/$i || exit 1; done |
60 | ' | |
706587fc | 61 | |
47e39c55 | 62 | # refs should all be different, but the trees should all be the same: |
706587fc EW |
63 | test_expect_success 'multi-fetch works on partial urls + paths' " |
64 | git-svn multi-fetch && | |
65 | for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do | |
66 | git rev-parse --verify refs/remotes/\$i^0 >> refs.out || exit 1; | |
67 | done && | |
68 | test -z \"\`sort < refs.out | uniq -d\`\" && | |
69 | for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do | |
70 | for j in trunk a b tags/0.1 tags/0.2 tags/0.3; do | |
71 | if test \$j != \$i; then continue; fi | |
72 | test -z \"\`git diff refs/remotes/\$i \ | |
73 | refs/remotes/\$j\`\" ||exit 1; done; done | |
74 | " | |
75 | ||
f69e836f | 76 | test_expect_success 'migrate --minimize on old inited layout' ' |
ccb6b6f5 EW |
77 | git config --unset-all svn-remote.svn.fetch && |
78 | git config --unset-all svn-remote.svn.url && | |
f69e836f BD |
79 | rm -rf "$GIT_DIR"/svn && |
80 | for i in `cat fetch.out`; do | |
81 | path=`expr $i : "\([^:]*\):.*$"` | |
82 | ref=`expr $i : "[^:]*:refs/remotes/\(.*\)$"` | |
83 | if test -z "$ref"; then continue; fi | |
84 | if test -n "$path"; then path="/$path"; fi | |
85 | ( mkdir -p "$GIT_DIR"/svn/$ref/info/ && | |
86 | echo "$svnrepo"$path > "$GIT_DIR"/svn/$ref/info/url ) || exit 1; | |
47e39c55 EW |
87 | done && |
88 | git-svn migrate --minimize && | |
f69e836f | 89 | test -z "`git config -l |grep -v "^svn-remote\.git-svn\."`" && |
5be60078 | 90 | git config --get-all svn-remote.svn.fetch > fetch.out && |
f69e836f BD |
91 | grep "^trunk:refs/remotes/trunk$" fetch.out && |
92 | grep "^branches/a:refs/remotes/a$" fetch.out && | |
93 | grep "^branches/b:refs/remotes/b$" fetch.out && | |
94 | grep "^tags/0\.1:refs/remotes/tags/0\.1$" fetch.out && | |
95 | grep "^tags/0\.2:refs/remotes/tags/0\.2$" fetch.out && | |
96 | grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out | |
97 | grep "^:refs/remotes/git-svn" fetch.out | |
98 | ' | |
47e39c55 | 99 | |
f69e836f | 100 | test_expect_success ".rev_db auto-converted to .rev_map.UUID" ' |
26a62d57 | 101 | git-svn fetch -i trunk && |
f69e836f BD |
102 | test -z "$(ls "$GIT_DIR"/svn/trunk/.rev_db.* 2>/dev/null)" && |
103 | expect="$(ls "$GIT_DIR"/svn/trunk/.rev_map.*)" && | |
104 | test -n "$expect" && | |
105 | rev_db="$(echo $expect | sed -e "s,_map,_db,")" && | |
106 | convert_to_rev_db "$expect" "$rev_db" && | |
107 | rm -f "$expect" && | |
108 | test -f "$rev_db" && | |
26a62d57 | 109 | git-svn fetch -i trunk && |
f69e836f BD |
110 | test -z "$(ls "$GIT_DIR"/svn/trunk/.rev_db.* 2>/dev/null)" && |
111 | test ! -e "$GIT_DIR"/svn/trunk/.rev_db && | |
112 | test -f "$expect" | |
113 | ' | |
26a62d57 | 114 | |
706587fc | 115 | test_done |