Merge branch 'sr/local-config'
[git/jnareb-git/bp-gitweb.git] / t / t9104-git-svn-follow-parent.sh
blobbbfd7f4793ab41118e7060bf7c0512309f81a546
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 &&
11 cd import &&
12 mkdir -p trunk &&
13 echo hello > trunk/readme &&
14 svn_cmd import -m "initial" . "$svnrepo" &&
15 cd .. &&
16 svn_cmd co "$svnrepo" wc &&
17 cd wc &&
18 echo world >> trunk/readme &&
19 poke trunk/readme &&
20 svn_cmd commit -m "another commit" &&
21 svn_cmd up &&
22 svn_cmd mv trunk thunk &&
23 echo goodbye >> thunk/readme &&
24 poke thunk/readme &&
25 svn_cmd commit -m "bye now" &&
26 cd ..
29 test_expect_success 'init and fetch a moved directory' '
30 git svn init --minimize-url -i thunk "$svnrepo"/thunk &&
31 git svn fetch -i thunk &&
32 test "`git rev-parse --verify refs/remotes/thunk@2`" \
33 = "`git rev-parse --verify refs/remotes/thunk~1`" &&
34 test "`git cat-file blob refs/remotes/thunk:readme |\
35 sed -n -e "3p"`" = goodbye &&
36 test -z "`git config --get svn-remote.svn.fetch \
37 "^trunk:refs/remotes/thunk@2$"`"
40 test_expect_success 'init and fetch from one svn-remote' '
41 git config svn-remote.svn.url "$svnrepo" &&
42 git config --add svn-remote.svn.fetch \
43 trunk:refs/remotes/svn/trunk &&
44 git config --add svn-remote.svn.fetch \
45 thunk:refs/remotes/svn/thunk &&
46 git svn fetch -i svn/thunk &&
47 test "`git rev-parse --verify refs/remotes/svn/trunk`" \
48 = "`git rev-parse --verify refs/remotes/svn/thunk~1`" &&
49 test "`git cat-file blob refs/remotes/svn/thunk:readme |\
50 sed -n -e "3p"`" = goodbye
53 test_expect_success 'follow deleted parent' '
54 (svn_cmd cp -m "resurrecting trunk as junk" \
55 "$svnrepo"/trunk@2 "$svnrepo"/junk ||
56 svn cp -m "resurrecting trunk as junk" \
57 -r2 "$svnrepo"/trunk "$svnrepo"/junk) &&
58 git config --add svn-remote.svn.fetch \
59 junk:refs/remotes/svn/junk &&
60 git svn fetch -i svn/thunk &&
61 git svn fetch -i svn/junk &&
62 test -z "`git diff svn/junk svn/trunk`" &&
63 test "`git merge-base svn/junk svn/trunk`" \
64 = "`git rev-parse svn/trunk`"
67 test_expect_success 'follow larger parent' '
68 mkdir -p import/trunk/thunk/bump/thud &&
69 echo hi > import/trunk/thunk/bump/thud/file &&
70 svn import -m "import a larger parent" import "$svnrepo"/larger-parent &&
71 svn cp -m "hi" "$svnrepo"/larger-parent "$svnrepo"/another-larger &&
72 git svn init --minimize-url -i larger \
73 "$svnrepo"/another-larger/trunk/thunk/bump/thud &&
74 git svn fetch -i larger &&
75 git rev-parse --verify refs/remotes/larger &&
76 git rev-parse --verify \
77 refs/remotes/larger-parent/trunk/thunk/bump/thud &&
78 test "`git merge-base \
79 refs/remotes/larger-parent/trunk/thunk/bump/thud \
80 refs/remotes/larger`" = \
81 "`git rev-parse refs/remotes/larger`"
82 true
85 test_expect_success 'follow higher-level parent' '
86 svn mkdir -m "follow higher-level parent" "$svnrepo"/blob &&
87 svn co "$svnrepo"/blob blob &&
88 cd blob &&
89 echo hi > hi &&
90 svn add hi &&
91 svn commit -m "hihi" &&
92 cd ..
93 svn mkdir -m "new glob at top level" "$svnrepo"/glob &&
94 svn mv -m "move blob down a level" "$svnrepo"/blob "$svnrepo"/glob/blob &&
95 git svn init --minimize-url -i blob "$svnrepo"/glob/blob &&
96 git svn fetch -i blob
99 test_expect_success 'follow deleted directory' '
100 svn_cmd mv -m "bye!" "$svnrepo"/glob/blob/hi "$svnrepo"/glob/blob/bye &&
101 svn_cmd rm -m "remove glob" "$svnrepo"/glob &&
102 git svn init --minimize-url -i glob "$svnrepo"/glob &&
103 git svn fetch -i glob &&
104 test "`git cat-file blob refs/remotes/glob:blob/bye`" = hi &&
105 test "`git ls-tree refs/remotes/glob | wc -l `" -eq 1
108 # ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn)
109 # in trunk/subversion/bindings/swig/perl
110 test_expect_success 'follow-parent avoids deleting relevant info' '
111 mkdir -p import/trunk/subversion/bindings/swig/perl/t &&
112 for i in a b c ; do \
113 echo $i > import/trunk/subversion/bindings/swig/perl/$i.pm &&
114 echo _$i > import/trunk/subversion/bindings/swig/perl/t/$i.t; \
115 done &&
116 echo "bad delete test" > \
117 import/trunk/subversion/bindings/swig/perl/t/larger-parent &&
118 echo "bad delete test 2" > \
119 import/trunk/subversion/bindings/swig/perl/another-larger &&
120 cd import &&
121 svn import -m "r9270 test" . "$svnrepo"/r9270 &&
122 cd .. &&
123 svn_cmd co "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl r9270 &&
124 cd r9270 &&
125 svn mkdir native &&
126 svn mv t native/t &&
127 for i in a b c; do svn mv $i.pm native/$i.pm; done &&
128 echo z >> native/t/c.t &&
129 poke native/t/c.t &&
130 svn commit -m "reorg test" &&
131 cd .. &&
132 git svn init --minimize-url -i r9270-t \
133 "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl/native/t &&
134 git svn fetch -i r9270-t &&
135 test `git rev-list r9270-t | wc -l` -eq 2 &&
136 test "`git ls-tree --name-only r9270-t~1`" = \
137 "`git ls-tree --name-only r9270-t`"
140 test_expect_success "track initial change if it was only made to parent" '
141 svn_cmd cp -m "wheee!" "$svnrepo"/r9270/trunk "$svnrepo"/r9270/drunk &&
142 git svn init --minimize-url -i r9270-d \
143 "$svnrepo"/r9270/drunk/subversion/bindings/swig/perl/native/t &&
144 git svn fetch -i r9270-d &&
145 test `git rev-list r9270-d | wc -l` -eq 3 &&
146 test "`git ls-tree --name-only r9270-t`" = \
147 "`git ls-tree --name-only r9270-d`" &&
148 test "`git rev-parse r9270-t`" = \
149 "`git rev-parse r9270-d~1`"
152 test_expect_success "follow-parent is atomic" '
154 cd wc &&
155 svn_cmd up &&
156 svn_cmd mkdir stunk &&
157 echo "trunk stunk" > stunk/readme &&
158 svn_cmd add stunk/readme &&
159 svn_cmd ci -m "trunk stunk" &&
160 echo "stunk like junk" >> stunk/readme &&
161 svn_cmd ci -m "really stunk" &&
162 echo "stink stank stunk" >> stunk/readme &&
163 svn_cmd ci -m "even the grinch agrees"
164 ) &&
165 svn_cmd copy -m "stunk flunked" "$svnrepo"/stunk "$svnrepo"/flunk &&
166 { svn cp -m "early stunk flunked too" \
167 "$svnrepo"/stunk@17 "$svnrepo"/flunked ||
168 svn_cmd cp -m "early stunk flunked too" \
169 -r17 "$svnrepo"/stunk "$svnrepo"/flunked; } &&
170 git svn init --minimize-url -i stunk "$svnrepo"/stunk &&
171 git svn fetch -i stunk &&
172 git update-ref refs/remotes/flunk@18 refs/remotes/stunk~2 &&
173 git update-ref -d refs/remotes/stunk &&
174 git config --unset svn-remote.svn.fetch stunk &&
175 mkdir -p "$GIT_DIR"/svn/refs/remotes/flunk@18 &&
176 rev_map=$(cd "$GIT_DIR"/svn/refs/remotes/stunk && ls .rev_map*) &&
177 dd if="$GIT_DIR"/svn/refs/remotes/stunk/$rev_map \
178 of="$GIT_DIR"/svn/refs/remotes/flunk@18/$rev_map bs=24 count=1 &&
179 rm -rf "$GIT_DIR"/svn/refs/remotes/stunk &&
180 git svn init --minimize-url -i flunk "$svnrepo"/flunk &&
181 git svn fetch -i flunk &&
182 git svn init --minimize-url -i stunk "$svnrepo"/stunk &&
183 git svn fetch -i stunk &&
184 git svn init --minimize-url -i flunked "$svnrepo"/flunked &&
185 git svn fetch -i flunked
186 test "`git rev-parse --verify refs/remotes/flunk@18`" \
187 = "`git rev-parse --verify refs/remotes/stunk`" &&
188 test "`git rev-parse --verify refs/remotes/flunk~1`" \
189 = "`git rev-parse --verify refs/remotes/stunk`" &&
190 test "`git rev-parse --verify refs/remotes/flunked~1`" \
191 = "`git rev-parse --verify refs/remotes/stunk~1`"
194 test_expect_success "track multi-parent paths" '
195 svn_cmd cp -m "resurrect /glob" "$svnrepo"/r9270 "$svnrepo"/glob &&
196 git svn multi-fetch &&
197 test `git cat-file commit refs/remotes/glob | \
198 grep "^parent " | wc -l` -eq 2
201 test_expect_success "multi-fetch continues to work" "
202 git svn multi-fetch
205 test_expect_success "multi-fetch works off a 'clean' repository" '
206 rm -r "$GIT_DIR/svn" "$GIT_DIR/refs/remotes" "$GIT_DIR/logs" &&
207 mkdir "$GIT_DIR/svn" &&
208 git svn multi-fetch
211 test_debug 'gitk --all &'
213 test_done