]> git.ipfire.org Git - thirdparty/git.git/blob - t/t9104-git-svn-follow-parent.sh
bisect--helper: plug strvec leak
[thirdparty/git.git] / t / t9104-git-svn-follow-parent.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2006 Eric Wong
4 #
5
6 test_description='git svn fetching'
7
8 TEST_FAILS_SANITIZE_LEAK=true
9 . ./lib-git-svn.sh
10
11 test_expect_success 'initialize repo' '
12 mkdir import &&
13 (
14 cd import &&
15 mkdir -p trunk &&
16 echo hello >trunk/readme &&
17 svn_cmd import -m "initial" . "$svnrepo"
18 ) &&
19 svn_cmd co "$svnrepo" wc &&
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"
30 )
31 '
32
33 test_expect_success 'init and fetch a moved directory' '
34 git svn init --minimize-url -i thunk "$svnrepo"/thunk &&
35 git svn fetch -i thunk &&
36 test "$(git rev-parse --verify refs/remotes/thunk@2)" \
37 = "$(git rev-parse --verify refs/remotes/thunk~1)" &&
38 git cat-file blob refs/remotes/thunk:readme >actual &&
39 test "$(sed -n -e "3p" actual)" = goodbye &&
40 test -z "$(git config --get svn-remote.svn.fetch \
41 "^trunk:refs/remotes/thunk@2$")"
42 '
43
44 test_expect_success 'init and fetch from one svn-remote' '
45 git config svn-remote.svn.url "$svnrepo" &&
46 git config --add svn-remote.svn.fetch \
47 trunk:refs/remotes/svn/trunk &&
48 git config --add svn-remote.svn.fetch \
49 thunk:refs/remotes/svn/thunk &&
50 git svn fetch -i svn/thunk &&
51 test "$(git rev-parse --verify refs/remotes/svn/trunk)" \
52 = "$(git rev-parse --verify refs/remotes/svn/thunk~1)" &&
53 git cat-file blob refs/remotes/svn/thunk:readme >actual &&
54 test "$(sed -n -e "3p" actual)" = goodbye
55 '
56
57 test_expect_success 'follow deleted parent' '
58 (svn_cmd cp -m "resurrecting trunk as junk" \
59 "$svnrepo"/trunk@2 "$svnrepo"/junk ||
60 svn cp -m "resurrecting trunk as junk" \
61 -r2 "$svnrepo"/trunk "$svnrepo"/junk) &&
62 git config --add svn-remote.svn.fetch \
63 junk:refs/remotes/svn/junk &&
64 git svn fetch -i svn/thunk &&
65 git svn fetch -i svn/junk &&
66 test -z "$(git diff svn/junk svn/trunk)" &&
67 test "$(git merge-base svn/junk svn/trunk)" \
68 = "$(git rev-parse svn/trunk)"
69 '
70
71 test_expect_success 'follow larger parent' '
72 mkdir -p import/trunk/thunk/bump/thud &&
73 echo hi > import/trunk/thunk/bump/thud/file &&
74 svn import -m "import a larger parent" import "$svnrepo"/larger-parent &&
75 svn cp -m "hi" "$svnrepo"/larger-parent "$svnrepo"/another-larger &&
76 git svn init --minimize-url -i larger \
77 "$svnrepo"/larger-parent/trunk/thunk/bump/thud &&
78 git svn fetch -i larger &&
79 git svn init --minimize-url -i larger-parent \
80 "$svnrepo"/another-larger/trunk/thunk/bump/thud &&
81 git svn fetch -i larger-parent &&
82 git rev-parse --verify refs/remotes/larger &&
83 git rev-parse --verify \
84 refs/remotes/larger-parent &&
85 test "$(git merge-base \
86 refs/remotes/larger-parent \
87 refs/remotes/larger)" = \
88 "$(git rev-parse refs/remotes/larger)"
89 '
90
91 test_expect_success 'follow higher-level parent' '
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 &&
98 svn commit -m "hihi"
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 &&
103 git svn fetch -i blob
104 '
105
106 test_expect_success 'follow deleted directory' '
107 svn_cmd mv -m "bye!" "$svnrepo"/glob/blob/hi "$svnrepo"/glob/blob/bye &&
108 svn_cmd rm -m "remove glob" "$svnrepo"/glob &&
109 git svn init --minimize-url -i glob "$svnrepo"/glob &&
110 git svn fetch -i glob &&
111 test "$(git cat-file blob refs/remotes/glob:blob/bye)" = hi &&
112 git ls-tree refs/remotes/glob >actual &&
113 test_line_count = 1 actual
114 '
115
116 # ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn)
117 # in trunk/subversion/bindings/swig/perl
118 test_expect_success 'follow-parent avoids deleting relevant info' '
119 mkdir -p import/trunk/subversion/bindings/swig/perl/t &&
120 for i in a b c ; do \
121 echo $i > import/trunk/subversion/bindings/swig/perl/$i.pm &&
122 echo _$i > import/trunk/subversion/bindings/swig/perl/t/$i.t || return 1
123 done &&
124 echo "bad delete test" > \
125 import/trunk/subversion/bindings/swig/perl/t/larger-parent &&
126 echo "bad delete test 2" > \
127 import/trunk/subversion/bindings/swig/perl/another-larger &&
128 (
129 cd import &&
130 svn import -m "r9270 test" . "$svnrepo"/r9270
131 ) &&
132 svn_cmd co "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl r9270 &&
133 (
134 cd r9270 &&
135 svn mkdir native &&
136 svn mv t native/t &&
137 for i in a b c
138 do
139 svn mv $i.pm native/$i.pm || return 1
140 done &&
141 echo z >>native/t/c.t &&
142 poke native/t/c.t &&
143 svn commit -m "reorg test"
144 ) &&
145 git svn init --minimize-url -i r9270-t \
146 "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl/native/t &&
147 git svn fetch -i r9270-t &&
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)"
151 '
152
153 test_expect_success "track initial change if it was only made to parent" '
154 svn_cmd cp -m "wheee!" "$svnrepo"/r9270/trunk "$svnrepo"/r9270/drunk &&
155 git svn init --minimize-url -i r9270-d \
156 "$svnrepo"/r9270/drunk/subversion/bindings/swig/perl/native/t &&
157 git svn fetch -i r9270-d &&
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)"
163 '
164
165 test_expect_success "follow-parent is atomic" '
166 record_size=$(($(test_oid rawsz) + 4)) &&
167 (
168 cd wc &&
169 svn_cmd up &&
170 svn_cmd mkdir stunk &&
171 echo "trunk stunk" > stunk/readme &&
172 svn_cmd add stunk/readme &&
173 svn_cmd ci -m "trunk stunk" &&
174 echo "stunk like junk" >> stunk/readme &&
175 svn_cmd ci -m "really stunk" &&
176 echo "stink stank stunk" >> stunk/readme &&
177 svn_cmd ci -m "even the grinch agrees"
178 ) &&
179 svn_cmd copy -m "stunk flunked" "$svnrepo"/stunk "$svnrepo"/flunk &&
180 { svn cp -m "early stunk flunked too" \
181 "$svnrepo"/stunk@17 "$svnrepo"/flunked ||
182 svn_cmd cp -m "early stunk flunked too" \
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 &&
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 \
192 of="$GIT_DIR"/svn/refs/remotes/flunk@18/$rev_map bs=$record_size count=1 &&
193 rm -rf "$GIT_DIR"/svn/refs/remotes/stunk &&
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 &&
199 git svn fetch -i flunked &&
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)"
206 '
207
208 test_expect_success "track multi-parent paths" '
209 svn_cmd cp -m "resurrect /glob" "$svnrepo"/r9270 "$svnrepo"/glob &&
210 git svn multi-fetch &&
211 git cat-file commit refs/remotes/glob >actual &&
212 grep "^parent " actual >actual2 &&
213 test_line_count = 2 actual2
214 '
215
216 test_expect_success "multi-fetch continues to work" "
217 git svn multi-fetch
218 "
219
220 test_expect_success "multi-fetch works off a 'clean' repository" '
221 rm -rf "$GIT_DIR/svn" &&
222 git for-each-ref --format="option no-deref%0adelete %(refname)" refs/remotes |
223 git update-ref --stdin &&
224 git reflog expire --all --expire=all &&
225 mkdir "$GIT_DIR/svn" &&
226 git svn multi-fetch
227 '
228
229 test_debug 'gitk --all &'
230
231 test_done