2 # Copyright (c) 2006 Eric Wong
3 test_description
='git svn metadata migrations from previous versions'
6 test_expect_success
'setup old-looking metadata' '
7 cp "$GIT_DIR"/config "$GIT_DIR"/config-old-git-svn &&
11 for i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3
14 echo hello >>$i/README ||
17 svn_cmd import -m test . "$svnrepo"
19 git svn init "$svnrepo" &&
21 rm -rf "$GIT_DIR"/svn &&
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
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'"
30 svnrepo_escaped
=$
(echo $svnrepo |
sed 's/ /%20/')
32 test_expect_success
'initialize old-style (v0) git svn layout' '
33 mkdir -p "$GIT_DIR"/git-svn/info "$GIT_DIR"/svn/info &&
34 echo "$svnrepo" > "$GIT_DIR"/git-svn/info/url &&
35 echo "$svnrepo" > "$GIT_DIR"/svn/info/url &&
37 ! test -d "$GIT_DIR"/git-svn &&
38 git rev-parse --verify refs/remotes/git-svn^0 &&
39 git rev-parse --verify refs/remotes/svn^0 &&
40 test "$(git config --get svn-remote.svn.url)" = "$svnrepo_escaped" &&
41 test $(git config --get svn-remote.svn.fetch) = \
42 ":refs/remotes/git-svn"
45 test_expect_success
'initialize a multi-repository repo' '
46 git svn init "$svnrepo" -T trunk -t tags -b branches &&
47 git config --get-all svn-remote.svn.fetch > fetch.out &&
48 grep "^trunk:refs/remotes/origin/trunk$" fetch.out &&
49 test -n "$(git config --get svn-remote.svn.branches \
50 "^branches/\*:refs/remotes/origin/\*$")" &&
51 test -n "$(git config --get svn-remote.svn.tags \
52 "^tags/\*:refs/remotes/origin/tags/\*$")" &&
53 git config --unset svn-remote.svn.branches \
54 "^branches/\*:refs/remotes/origin/\*$" &&
55 git config --unset svn-remote.svn.tags \
56 "^tags/\*:refs/remotes/origin/tags/\*$" &&
57 git config --add svn-remote.svn.fetch "branches/a:refs/remotes/origin/a" &&
58 git config --add svn-remote.svn.fetch "branches/b:refs/remotes/origin/b" &&
59 for i in tags/0.1 tags/0.2 tags/0.3
61 git config --add svn-remote.svn.fetch \
62 $i:refs/remotes/origin/$i || return 1
64 git config --get-all svn-remote.svn.fetch > fetch.out &&
65 grep "^trunk:refs/remotes/origin/trunk$" fetch.out &&
66 grep "^branches/a:refs/remotes/origin/a$" fetch.out &&
67 grep "^branches/b:refs/remotes/origin/b$" fetch.out &&
68 grep "^tags/0\.1:refs/remotes/origin/tags/0\.1$" fetch.out &&
69 grep "^tags/0\.2:refs/remotes/origin/tags/0\.2$" fetch.out &&
70 grep "^tags/0\.3:refs/remotes/origin/tags/0\.3$" fetch.out &&
71 grep "^:refs/remotes/git-svn" fetch.out
74 # refs should all be different, but the trees should all be the same:
75 test_expect_success
'multi-fetch works on partial urls + paths' '
76 refs="trunk a b tags/0.1 tags/0.2 tags/0.3" &&
77 git svn multi-fetch &&
80 git rev-parse --verify refs/remotes/origin/$i^0 || return 1;
82 test -z "$(sort <refs.out | uniq -d)" &&
87 git diff --exit-code refs/remotes/origin/$i \
88 refs/remotes/origin/$j ||
94 test_expect_success
'migrate --minimize on old inited layout' '
95 git config --unset-all svn-remote.svn.fetch &&
96 git config --unset-all svn-remote.svn.url &&
97 rm -rf "$GIT_DIR"/svn &&
98 for i in $(cat fetch.out)
100 path=$(expr $i : "\([^:]*\):.*$")
101 ref=$(expr $i : "[^:]*:\(refs/remotes/.*\)$")
102 if test -z "$ref"; then continue; fi
103 if test -n "$path"; then path="/$path"; fi
104 mkdir -p "$GIT_DIR"/svn/$ref/info/ &&
105 echo "$svnrepo"$path >"$GIT_DIR"/svn/$ref/info/url ||
108 git svn migrate --minimize &&
109 test -z "$(git config -l | grep "^svn-remote\.git-svn\.")" &&
110 git config --get-all svn-remote.svn.fetch > fetch.out &&
111 grep "^trunk:refs/remotes/origin/trunk$" fetch.out &&
112 grep "^branches/a:refs/remotes/origin/a$" fetch.out &&
113 grep "^branches/b:refs/remotes/origin/b$" fetch.out &&
114 grep "^tags/0\.1:refs/remotes/origin/tags/0\.1$" fetch.out &&
115 grep "^tags/0\.2:refs/remotes/origin/tags/0\.2$" fetch.out &&
116 grep "^tags/0\.3:refs/remotes/origin/tags/0\.3$" fetch.out &&
117 grep "^:refs/remotes/git-svn" fetch.out
120 test_expect_success
".rev_db auto-converted to .rev_map.UUID" '
121 git svn fetch -i trunk &&
122 test -z "$(ls "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_db.* 2>/dev/null)" &&
123 expect="$(ls "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_map.*)" &&
125 rev_db="$(echo $expect | sed -e "s,_map,_db,")" &&
126 convert_to_rev_db "$expect" "$rev_db" &&
129 git svn fetch -i trunk &&
130 test -z "$(ls "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_db.* 2>/dev/null)" &&
131 test ! -e "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_db &&