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