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