]>
Commit | Line | Data |
---|---|---|
a00439ac EW |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Eric Wong | |
4 | # | |
5 | ||
1364ff27 | 6 | test_description='git svn fetching' |
7a98d9ab ÆAB |
7 | |
8 | TEST_FAILS_SANITIZE_LEAK=true | |
a00439ac EW |
9 | . ./lib-git-svn.sh |
10 | ||
f69e836f | 11 | test_expect_success 'initialize repo' ' |
a00439ac | 12 | mkdir import && |
18a82692 JN |
13 | ( |
14 | cd import && | |
15 | mkdir -p trunk && | |
16 | echo hello >trunk/readme && | |
17 | svn_cmd import -m "initial" . "$svnrepo" | |
fd4ec4f2 | 18 | ) && |
da083d68 | 19 | svn_cmd co "$svnrepo" wc && |
18a82692 JN |
20 | ( |
21 | cd wc && | |
22 | echo world >>trunk/readme && | |
23 | poke trunk/readme && | |
24 | svn_cmd commit -m "another commit" && | |
25 | svn_cmd up && | |
26 | svn_cmd mv trunk thunk && | |
27 | echo goodbye >>thunk/readme && | |
28 | poke thunk/readme && | |
29 | svn_cmd commit -m "bye now" | |
fd4ec4f2 | 30 | ) |
f69e836f | 31 | ' |
a00439ac | 32 | |
f69e836f | 33 | test_expect_success 'init and fetch a moved directory' ' |
1364ff27 NS |
34 | git svn init --minimize-url -i thunk "$svnrepo"/thunk && |
35 | git svn fetch -i thunk && | |
cd914d80 EP |
36 | test "$(git rev-parse --verify refs/remotes/thunk@2)" \ |
37 | = "$(git rev-parse --verify refs/remotes/thunk~1)" && | |
a4d4e32a PK |
38 | git cat-file blob refs/remotes/thunk:readme >actual && |
39 | test "$(sed -n -e "3p" actual)" = goodbye && | |
cd914d80 EP |
40 | test -z "$(git config --get svn-remote.svn.fetch \ |
41 | "^trunk:refs/remotes/thunk@2$")" | |
f69e836f | 42 | ' |
a00439ac | 43 | |
f69e836f BD |
44 | test_expect_success 'init and fetch from one svn-remote' ' |
45 | git config svn-remote.svn.url "$svnrepo" && | |
5be60078 | 46 | git config --add svn-remote.svn.fetch \ |
8b8fc068 | 47 | trunk:refs/remotes/svn/trunk && |
5be60078 | 48 | git config --add svn-remote.svn.fetch \ |
8b8fc068 | 49 | thunk:refs/remotes/svn/thunk && |
1364ff27 | 50 | git svn fetch -i svn/thunk && |
cd914d80 EP |
51 | test "$(git rev-parse --verify refs/remotes/svn/trunk)" \ |
52 | = "$(git rev-parse --verify refs/remotes/svn/thunk~1)" && | |
a4d4e32a PK |
53 | git cat-file blob refs/remotes/svn/thunk:readme >actual && |
54 | test "$(sed -n -e "3p" actual)" = goodbye | |
f69e836f | 55 | ' |
8b8fc068 | 56 | |
f69e836f | 57 | test_expect_success 'follow deleted parent' ' |
da083d68 | 58 | (svn_cmd cp -m "resurrecting trunk as junk" \ |
f69e836f BD |
59 | "$svnrepo"/trunk@2 "$svnrepo"/junk || |
60 | svn cp -m "resurrecting trunk as junk" \ | |
61 | -r2 "$svnrepo"/trunk "$svnrepo"/junk) && | |
5be60078 | 62 | git config --add svn-remote.svn.fetch \ |
a2003abc | 63 | junk:refs/remotes/svn/junk && |
1364ff27 NS |
64 | git svn fetch -i svn/thunk && |
65 | git svn fetch -i svn/junk && | |
cd914d80 EP |
66 | test -z "$(git diff svn/junk svn/trunk)" && |
67 | test "$(git merge-base svn/junk svn/trunk)" \ | |
68 | = "$(git rev-parse svn/trunk)" | |
f69e836f | 69 | ' |
a2003abc | 70 | |
f69e836f | 71 | test_expect_success 'follow larger parent' ' |
7f578c55 EW |
72 | mkdir -p import/trunk/thunk/bump/thud && |
73 | echo hi > import/trunk/thunk/bump/thud/file && | |
f69e836f BD |
74 | svn import -m "import a larger parent" import "$svnrepo"/larger-parent && |
75 | svn cp -m "hi" "$svnrepo"/larger-parent "$svnrepo"/another-larger && | |
1364ff27 | 76 | git svn init --minimize-url -i larger \ |
b7a06e00 | 77 | "$svnrepo"/larger-parent/trunk/thunk/bump/thud && |
1364ff27 | 78 | git svn fetch -i larger && |
b7a06e00 MG |
79 | git svn init --minimize-url -i larger-parent \ |
80 | "$svnrepo"/another-larger/trunk/thunk/bump/thud && | |
81 | git svn fetch -i larger-parent && | |
5be60078 JH |
82 | git rev-parse --verify refs/remotes/larger && |
83 | git rev-parse --verify \ | |
b7a06e00 | 84 | refs/remotes/larger-parent && |
cd914d80 | 85 | test "$(git merge-base \ |
b7a06e00 | 86 | refs/remotes/larger-parent \ |
cd914d80 EP |
87 | refs/remotes/larger)" = \ |
88 | "$(git rev-parse refs/remotes/larger)" | |
f69e836f | 89 | ' |
7f578c55 | 90 | |
f69e836f | 91 | test_expect_success 'follow higher-level parent' ' |
18a82692 JN |
92 | svn mkdir -m "follow higher-level parent" "$svnrepo"/blob && |
93 | svn co "$svnrepo"/blob blob && | |
94 | ( | |
95 | cd blob && | |
96 | echo hi > hi && | |
97 | svn add hi && | |
fd4ec4f2 | 98 | svn commit -m "hihi" |
18a82692 JN |
99 | ) && |
100 | svn mkdir -m "new glob at top level" "$svnrepo"/glob && | |
101 | svn mv -m "move blob down a level" "$svnrepo"/blob "$svnrepo"/glob/blob && | |
102 | git svn init --minimize-url -i blob "$svnrepo"/glob/blob && | |
1364ff27 | 103 | git svn fetch -i blob |
f69e836f | 104 | ' |
1492b424 | 105 | |
f69e836f | 106 | test_expect_success 'follow deleted directory' ' |
da083d68 ER |
107 | svn_cmd mv -m "bye!" "$svnrepo"/glob/blob/hi "$svnrepo"/glob/blob/bye && |
108 | svn_cmd rm -m "remove glob" "$svnrepo"/glob && | |
1364ff27 NS |
109 | git svn init --minimize-url -i glob "$svnrepo"/glob && |
110 | git svn fetch -i glob && | |
cd914d80 | 111 | test "$(git cat-file blob refs/remotes/glob:blob/bye)" = hi && |
a4d4e32a PK |
112 | git ls-tree refs/remotes/glob >actual && |
113 | test_line_count = 1 actual | |
f69e836f | 114 | ' |
e5a0b240 | 115 | |
2b27f6c8 EW |
116 | # ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn) |
117 | # in trunk/subversion/bindings/swig/perl | |
f69e836f | 118 | test_expect_success 'follow-parent avoids deleting relevant info' ' |
2b27f6c8 EW |
119 | mkdir -p import/trunk/subversion/bindings/swig/perl/t && |
120 | for i in a b c ; do \ | |
f69e836f | 121 | echo $i > import/trunk/subversion/bindings/swig/perl/$i.pm && |
0c51d6b4 | 122 | echo _$i > import/trunk/subversion/bindings/swig/perl/t/$i.t || return 1 |
2b27f6c8 | 123 | done && |
f69e836f | 124 | echo "bad delete test" > \ |
2b27f6c8 | 125 | import/trunk/subversion/bindings/swig/perl/t/larger-parent && |
f69e836f | 126 | echo "bad delete test 2" > \ |
2b27f6c8 | 127 | import/trunk/subversion/bindings/swig/perl/another-larger && |
18a82692 JN |
128 | ( |
129 | cd import && | |
130 | svn import -m "r9270 test" . "$svnrepo"/r9270 | |
fd4ec4f2 | 131 | ) && |
da083d68 | 132 | svn_cmd co "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl r9270 && |
18a82692 JN |
133 | ( |
134 | cd r9270 && | |
135 | svn mkdir native && | |
136 | svn mv t native/t && | |
137 | for i in a b c | |
138 | do | |
0c51d6b4 | 139 | svn mv $i.pm native/$i.pm || return 1 |
18a82692 JN |
140 | done && |
141 | echo z >>native/t/c.t && | |
142 | poke native/t/c.t && | |
143 | svn commit -m "reorg test" | |
fd4ec4f2 | 144 | ) && |
1364ff27 | 145 | git svn init --minimize-url -i r9270-t \ |
f69e836f | 146 | "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl/native/t && |
1364ff27 | 147 | git svn fetch -i r9270-t && |
cd914d80 EP |
148 | test $(git rev-list r9270-t | wc -l) -eq 2 && |
149 | test "$(git ls-tree --name-only r9270-t~1)" = \ | |
150 | "$(git ls-tree --name-only r9270-t)" | |
f69e836f | 151 | ' |
2b27f6c8 | 152 | |
f69e836f | 153 | test_expect_success "track initial change if it was only made to parent" ' |
da083d68 | 154 | svn_cmd cp -m "wheee!" "$svnrepo"/r9270/trunk "$svnrepo"/r9270/drunk && |
1364ff27 | 155 | git svn init --minimize-url -i r9270-d \ |
f69e836f | 156 | "$svnrepo"/r9270/drunk/subversion/bindings/swig/perl/native/t && |
1364ff27 | 157 | git svn fetch -i r9270-d && |
cd914d80 EP |
158 | test $(git rev-list r9270-d | wc -l) -eq 3 && |
159 | test "$(git ls-tree --name-only r9270-t)" = \ | |
160 | "$(git ls-tree --name-only r9270-d)" && | |
161 | test "$(git rev-parse r9270-t)" = \ | |
162 | "$(git rev-parse r9270-d~1)" | |
f69e836f | 163 | ' |
28937057 | 164 | |
553589f7 | 165 | test_expect_success "follow-parent is atomic" ' |
bbe0616c | 166 | record_size=$(($(test_oid rawsz) + 4)) && |
553589f7 DM |
167 | ( |
168 | cd wc && | |
da083d68 ER |
169 | svn_cmd up && |
170 | svn_cmd mkdir stunk && | |
553589f7 | 171 | echo "trunk stunk" > stunk/readme && |
da083d68 ER |
172 | svn_cmd add stunk/readme && |
173 | svn_cmd ci -m "trunk stunk" && | |
553589f7 | 174 | echo "stunk like junk" >> stunk/readme && |
da083d68 | 175 | svn_cmd ci -m "really stunk" && |
553589f7 | 176 | echo "stink stank stunk" >> stunk/readme && |
da083d68 | 177 | svn_cmd ci -m "even the grinch agrees" |
553589f7 | 178 | ) && |
da083d68 | 179 | svn_cmd copy -m "stunk flunked" "$svnrepo"/stunk "$svnrepo"/flunk && |
553589f7 DM |
180 | { svn cp -m "early stunk flunked too" \ |
181 | "$svnrepo"/stunk@17 "$svnrepo"/flunked || | |
da083d68 | 182 | svn_cmd cp -m "early stunk flunked too" \ |
553589f7 DM |
183 | -r17 "$svnrepo"/stunk "$svnrepo"/flunked; } && |
184 | git svn init --minimize-url -i stunk "$svnrepo"/stunk && | |
185 | git svn fetch -i stunk && | |
186 | git update-ref refs/remotes/flunk@18 refs/remotes/stunk~2 && | |
187 | git update-ref -d refs/remotes/stunk && | |
188 | git config --unset svn-remote.svn.fetch stunk && | |
6f5748e1 AB |
189 | mkdir -p "$GIT_DIR"/svn/refs/remotes/flunk@18 && |
190 | rev_map=$(cd "$GIT_DIR"/svn/refs/remotes/stunk && ls .rev_map*) && | |
191 | dd if="$GIT_DIR"/svn/refs/remotes/stunk/$rev_map \ | |
bbe0616c | 192 | of="$GIT_DIR"/svn/refs/remotes/flunk@18/$rev_map bs=$record_size count=1 && |
6f5748e1 | 193 | rm -rf "$GIT_DIR"/svn/refs/remotes/stunk && |
553589f7 DM |
194 | git svn init --minimize-url -i flunk "$svnrepo"/flunk && |
195 | git svn fetch -i flunk && | |
196 | git svn init --minimize-url -i stunk "$svnrepo"/stunk && | |
197 | git svn fetch -i stunk && | |
198 | git svn init --minimize-url -i flunked "$svnrepo"/flunked && | |
a48fcd83 | 199 | git svn fetch -i flunked && |
cd914d80 EP |
200 | test "$(git rev-parse --verify refs/remotes/flunk@18)" \ |
201 | = "$(git rev-parse --verify refs/remotes/stunk)" && | |
202 | test "$(git rev-parse --verify refs/remotes/flunk~1)" \ | |
203 | = "$(git rev-parse --verify refs/remotes/stunk)" && | |
204 | test "$(git rev-parse --verify refs/remotes/flunked~1)" \ | |
205 | = "$(git rev-parse --verify refs/remotes/stunk~1)" | |
553589f7 DM |
206 | ' |
207 | ||
f69e836f | 208 | test_expect_success "track multi-parent paths" ' |
da083d68 | 209 | svn_cmd cp -m "resurrect /glob" "$svnrepo"/r9270 "$svnrepo"/glob && |
1364ff27 | 210 | git svn multi-fetch && |
a4d4e32a PK |
211 | git cat-file commit refs/remotes/glob >actual && |
212 | grep "^parent " actual >actual2 && | |
213 | test_line_count = 2 actual2 | |
f69e836f | 214 | ' |
b9dffd8c | 215 | |
8a603774 | 216 | test_expect_success "multi-fetch continues to work" " |
1364ff27 | 217 | git svn multi-fetch |
8a603774 EW |
218 | " |
219 | ||
f69e836f | 220 | test_expect_success "multi-fetch works off a 'clean' repository" ' |
78f28e2a CC |
221 | rm -rf "$GIT_DIR/svn" && |
222 | git for-each-ref --format="option no-deref%0adelete %(refname)" refs/remotes | | |
223 | git update-ref --stdin && | |
cbc5cf7c | 224 | git reflog expire --all --expire=all && |
f69e836f | 225 | mkdir "$GIT_DIR/svn" && |
1364ff27 | 226 | git svn multi-fetch |
f69e836f | 227 | ' |
8a603774 | 228 | |
a00439ac EW |
229 | test_debug 'gitk --all &' |
230 | ||
231 | test_done |