pathspec: create parse_short_magic function
[alt-git.git] / t / t9104-git-svn-follow-parent.sh
blobcd480edf1606fda8d973ee3decb8e18e03356153
1 #!/bin/sh
3 # Copyright (c) 2006 Eric Wong
6 test_description='git svn fetching'
7 . ./lib-git-svn.sh
9 test_expect_success 'initialize repo' '
10 mkdir import &&
12 cd import &&
13 mkdir -p trunk &&
14 echo hello >trunk/readme &&
15 svn_cmd import -m "initial" . "$svnrepo"
16 ) &&
17 svn_cmd co "$svnrepo" wc &&
19 cd wc &&
20 echo world >>trunk/readme &&
21 poke trunk/readme &&
22 svn_cmd commit -m "another commit" &&
23 svn_cmd up &&
24 svn_cmd mv trunk thunk &&
25 echo goodbye >>thunk/readme &&
26 poke thunk/readme &&
27 svn_cmd commit -m "bye now"
31 test_expect_success 'init and fetch a moved directory' '
32 git svn init --minimize-url -i thunk "$svnrepo"/thunk &&
33 git svn fetch -i thunk &&
34 test "$(git rev-parse --verify refs/remotes/thunk@2)" \
35 = "$(git rev-parse --verify refs/remotes/thunk~1)" &&
36 test "$(git cat-file blob refs/remotes/thunk:readme |\
37 sed -n -e "3p")" = goodbye &&
38 test -z "$(git config --get svn-remote.svn.fetch \
39 "^trunk:refs/remotes/thunk@2$")"
42 test_expect_success 'init and fetch from one svn-remote' '
43 git config svn-remote.svn.url "$svnrepo" &&
44 git config --add svn-remote.svn.fetch \
45 trunk:refs/remotes/svn/trunk &&
46 git config --add svn-remote.svn.fetch \
47 thunk:refs/remotes/svn/thunk &&
48 git svn fetch -i svn/thunk &&
49 test "$(git rev-parse --verify refs/remotes/svn/trunk)" \
50 = "$(git rev-parse --verify refs/remotes/svn/thunk~1)" &&
51 test "$(git cat-file blob refs/remotes/svn/thunk:readme |\
52 sed -n -e "3p")" = goodbye
55 test_expect_success 'follow deleted parent' '
56 (svn_cmd cp -m "resurrecting trunk as junk" \
57 "$svnrepo"/trunk@2 "$svnrepo"/junk ||
58 svn cp -m "resurrecting trunk as junk" \
59 -r2 "$svnrepo"/trunk "$svnrepo"/junk) &&
60 git config --add svn-remote.svn.fetch \
61 junk:refs/remotes/svn/junk &&
62 git svn fetch -i svn/thunk &&
63 git svn fetch -i svn/junk &&
64 test -z "$(git diff svn/junk svn/trunk)" &&
65 test "$(git merge-base svn/junk svn/trunk)" \
66 = "$(git rev-parse svn/trunk)"
69 test_expect_success 'follow larger parent' '
70 mkdir -p import/trunk/thunk/bump/thud &&
71 echo hi > import/trunk/thunk/bump/thud/file &&
72 svn import -m "import a larger parent" import "$svnrepo"/larger-parent &&
73 svn cp -m "hi" "$svnrepo"/larger-parent "$svnrepo"/another-larger &&
74 git svn init --minimize-url -i larger \
75 "$svnrepo"/larger-parent/trunk/thunk/bump/thud &&
76 git svn fetch -i larger &&
77 git svn init --minimize-url -i larger-parent \
78 "$svnrepo"/another-larger/trunk/thunk/bump/thud &&
79 git svn fetch -i larger-parent &&
80 git rev-parse --verify refs/remotes/larger &&
81 git rev-parse --verify \
82 refs/remotes/larger-parent &&
83 test "$(git merge-base \
84 refs/remotes/larger-parent \
85 refs/remotes/larger)" = \
86 "$(git rev-parse refs/remotes/larger)"
89 test_expect_success 'follow higher-level parent' '
90 svn mkdir -m "follow higher-level parent" "$svnrepo"/blob &&
91 svn co "$svnrepo"/blob blob &&
93 cd blob &&
94 echo hi > hi &&
95 svn add hi &&
96 svn commit -m "hihi"
97 ) &&
98 svn mkdir -m "new glob at top level" "$svnrepo"/glob &&
99 svn mv -m "move blob down a level" "$svnrepo"/blob "$svnrepo"/glob/blob &&
100 git svn init --minimize-url -i blob "$svnrepo"/glob/blob &&
101 git svn fetch -i blob
104 test_expect_success 'follow deleted directory' '
105 svn_cmd mv -m "bye!" "$svnrepo"/glob/blob/hi "$svnrepo"/glob/blob/bye &&
106 svn_cmd rm -m "remove glob" "$svnrepo"/glob &&
107 git svn init --minimize-url -i glob "$svnrepo"/glob &&
108 git svn fetch -i glob &&
109 test "$(git cat-file blob refs/remotes/glob:blob/bye)" = hi &&
110 test "$(git ls-tree refs/remotes/glob | wc -l )" -eq 1
113 # ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn)
114 # in trunk/subversion/bindings/swig/perl
115 test_expect_success 'follow-parent avoids deleting relevant info' '
116 mkdir -p import/trunk/subversion/bindings/swig/perl/t &&
117 for i in a b c ; do \
118 echo $i > import/trunk/subversion/bindings/swig/perl/$i.pm &&
119 echo _$i > import/trunk/subversion/bindings/swig/perl/t/$i.t; \
120 done &&
121 echo "bad delete test" > \
122 import/trunk/subversion/bindings/swig/perl/t/larger-parent &&
123 echo "bad delete test 2" > \
124 import/trunk/subversion/bindings/swig/perl/another-larger &&
126 cd import &&
127 svn import -m "r9270 test" . "$svnrepo"/r9270
128 ) &&
129 svn_cmd co "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl r9270 &&
131 cd r9270 &&
132 svn mkdir native &&
133 svn mv t native/t &&
134 for i in a b c
136 svn mv $i.pm native/$i.pm
137 done &&
138 echo z >>native/t/c.t &&
139 poke native/t/c.t &&
140 svn commit -m "reorg test"
141 ) &&
142 git svn init --minimize-url -i r9270-t \
143 "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl/native/t &&
144 git svn fetch -i r9270-t &&
145 test $(git rev-list r9270-t | wc -l) -eq 2 &&
146 test "$(git ls-tree --name-only r9270-t~1)" = \
147 "$(git ls-tree --name-only r9270-t)"
150 test_expect_success "track initial change if it was only made to parent" '
151 svn_cmd cp -m "wheee!" "$svnrepo"/r9270/trunk "$svnrepo"/r9270/drunk &&
152 git svn init --minimize-url -i r9270-d \
153 "$svnrepo"/r9270/drunk/subversion/bindings/swig/perl/native/t &&
154 git svn fetch -i r9270-d &&
155 test $(git rev-list r9270-d | wc -l) -eq 3 &&
156 test "$(git ls-tree --name-only r9270-t)" = \
157 "$(git ls-tree --name-only r9270-d)" &&
158 test "$(git rev-parse r9270-t)" = \
159 "$(git rev-parse r9270-d~1)"
162 test_expect_success "follow-parent is atomic" '
164 cd wc &&
165 svn_cmd up &&
166 svn_cmd mkdir stunk &&
167 echo "trunk stunk" > stunk/readme &&
168 svn_cmd add stunk/readme &&
169 svn_cmd ci -m "trunk stunk" &&
170 echo "stunk like junk" >> stunk/readme &&
171 svn_cmd ci -m "really stunk" &&
172 echo "stink stank stunk" >> stunk/readme &&
173 svn_cmd ci -m "even the grinch agrees"
174 ) &&
175 svn_cmd copy -m "stunk flunked" "$svnrepo"/stunk "$svnrepo"/flunk &&
176 { svn cp -m "early stunk flunked too" \
177 "$svnrepo"/stunk@17 "$svnrepo"/flunked ||
178 svn_cmd cp -m "early stunk flunked too" \
179 -r17 "$svnrepo"/stunk "$svnrepo"/flunked; } &&
180 git svn init --minimize-url -i stunk "$svnrepo"/stunk &&
181 git svn fetch -i stunk &&
182 git update-ref refs/remotes/flunk@18 refs/remotes/stunk~2 &&
183 git update-ref -d refs/remotes/stunk &&
184 git config --unset svn-remote.svn.fetch stunk &&
185 mkdir -p "$GIT_DIR"/svn/refs/remotes/flunk@18 &&
186 rev_map=$(cd "$GIT_DIR"/svn/refs/remotes/stunk && ls .rev_map*) &&
187 dd if="$GIT_DIR"/svn/refs/remotes/stunk/$rev_map \
188 of="$GIT_DIR"/svn/refs/remotes/flunk@18/$rev_map bs=24 count=1 &&
189 rm -rf "$GIT_DIR"/svn/refs/remotes/stunk &&
190 git svn init --minimize-url -i flunk "$svnrepo"/flunk &&
191 git svn fetch -i flunk &&
192 git svn init --minimize-url -i stunk "$svnrepo"/stunk &&
193 git svn fetch -i stunk &&
194 git svn init --minimize-url -i flunked "$svnrepo"/flunked &&
195 git svn fetch -i flunked &&
196 test "$(git rev-parse --verify refs/remotes/flunk@18)" \
197 = "$(git rev-parse --verify refs/remotes/stunk)" &&
198 test "$(git rev-parse --verify refs/remotes/flunk~1)" \
199 = "$(git rev-parse --verify refs/remotes/stunk)" &&
200 test "$(git rev-parse --verify refs/remotes/flunked~1)" \
201 = "$(git rev-parse --verify refs/remotes/stunk~1)"
204 test_expect_success "track multi-parent paths" '
205 svn_cmd cp -m "resurrect /glob" "$svnrepo"/r9270 "$svnrepo"/glob &&
206 git svn multi-fetch &&
207 test $(git cat-file commit refs/remotes/glob | \
208 grep "^parent " | wc -l) -eq 2
211 test_expect_success "multi-fetch continues to work" "
212 git svn multi-fetch
215 test_expect_success "multi-fetch works off a 'clean' repository" '
216 rm -r "$GIT_DIR/svn" "$GIT_DIR/refs/remotes" "$GIT_DIR/logs" &&
217 mkdir "$GIT_DIR/svn" &&
218 git svn multi-fetch
221 test_debug 'gitk --all &'
223 test_done