commit: error out for missing commit message template
[git.git] / t / t9104-git-svn-follow-parent.sh
blobf7f3c5ab8ef8dd822a51d6c97281ba077c511642
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"/another-larger/trunk/thunk/bump/thud &&
76 git svn fetch -i larger &&
77 git rev-parse --verify refs/remotes/larger &&
78 git rev-parse --verify \
79 refs/remotes/larger-parent/trunk/thunk/bump/thud &&
80 test "`git merge-base \
81 refs/remotes/larger-parent/trunk/thunk/bump/thud \
82 refs/remotes/larger`" = \
83 "`git rev-parse refs/remotes/larger`"
84 true
87 test_expect_success 'follow higher-level parent' '
88 svn mkdir -m "follow higher-level parent" "$svnrepo"/blob &&
89 svn co "$svnrepo"/blob blob &&
91 cd blob &&
92 echo hi > hi &&
93 svn add hi &&
94 svn commit -m "hihi"
95 ) &&
96 svn mkdir -m "new glob at top level" "$svnrepo"/glob &&
97 svn mv -m "move blob down a level" "$svnrepo"/blob "$svnrepo"/glob/blob &&
98 git svn init --minimize-url -i blob "$svnrepo"/glob/blob &&
99 git svn fetch -i blob
102 test_expect_success 'follow deleted directory' '
103 svn_cmd mv -m "bye!" "$svnrepo"/glob/blob/hi "$svnrepo"/glob/blob/bye &&
104 svn_cmd rm -m "remove glob" "$svnrepo"/glob &&
105 git svn init --minimize-url -i glob "$svnrepo"/glob &&
106 git svn fetch -i glob &&
107 test "`git cat-file blob refs/remotes/glob:blob/bye`" = hi &&
108 test "`git ls-tree refs/remotes/glob | wc -l `" -eq 1
111 # ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn)
112 # in trunk/subversion/bindings/swig/perl
113 test_expect_success 'follow-parent avoids deleting relevant info' '
114 mkdir -p import/trunk/subversion/bindings/swig/perl/t &&
115 for i in a b c ; do \
116 echo $i > import/trunk/subversion/bindings/swig/perl/$i.pm &&
117 echo _$i > import/trunk/subversion/bindings/swig/perl/t/$i.t; \
118 done &&
119 echo "bad delete test" > \
120 import/trunk/subversion/bindings/swig/perl/t/larger-parent &&
121 echo "bad delete test 2" > \
122 import/trunk/subversion/bindings/swig/perl/another-larger &&
124 cd import &&
125 svn import -m "r9270 test" . "$svnrepo"/r9270
126 ) &&
127 svn_cmd co "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl r9270 &&
129 cd r9270 &&
130 svn mkdir native &&
131 svn mv t native/t &&
132 for i in a b c
134 svn mv $i.pm native/$i.pm
135 done &&
136 echo z >>native/t/c.t &&
137 poke native/t/c.t &&
138 svn commit -m "reorg test"
139 ) &&
140 git svn init --minimize-url -i r9270-t \
141 "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl/native/t &&
142 git svn fetch -i r9270-t &&
143 test `git rev-list r9270-t | wc -l` -eq 2 &&
144 test "`git ls-tree --name-only r9270-t~1`" = \
145 "`git ls-tree --name-only r9270-t`"
148 test_expect_success "track initial change if it was only made to parent" '
149 svn_cmd cp -m "wheee!" "$svnrepo"/r9270/trunk "$svnrepo"/r9270/drunk &&
150 git svn init --minimize-url -i r9270-d \
151 "$svnrepo"/r9270/drunk/subversion/bindings/swig/perl/native/t &&
152 git svn fetch -i r9270-d &&
153 test `git rev-list r9270-d | wc -l` -eq 3 &&
154 test "`git ls-tree --name-only r9270-t`" = \
155 "`git ls-tree --name-only r9270-d`" &&
156 test "`git rev-parse r9270-t`" = \
157 "`git rev-parse r9270-d~1`"
160 test_expect_success "follow-parent is atomic" '
162 cd wc &&
163 svn_cmd up &&
164 svn_cmd mkdir stunk &&
165 echo "trunk stunk" > stunk/readme &&
166 svn_cmd add stunk/readme &&
167 svn_cmd ci -m "trunk stunk" &&
168 echo "stunk like junk" >> stunk/readme &&
169 svn_cmd ci -m "really stunk" &&
170 echo "stink stank stunk" >> stunk/readme &&
171 svn_cmd ci -m "even the grinch agrees"
172 ) &&
173 svn_cmd copy -m "stunk flunked" "$svnrepo"/stunk "$svnrepo"/flunk &&
174 { svn cp -m "early stunk flunked too" \
175 "$svnrepo"/stunk@17 "$svnrepo"/flunked ||
176 svn_cmd cp -m "early stunk flunked too" \
177 -r17 "$svnrepo"/stunk "$svnrepo"/flunked; } &&
178 git svn init --minimize-url -i stunk "$svnrepo"/stunk &&
179 git svn fetch -i stunk &&
180 git update-ref refs/remotes/flunk@18 refs/remotes/stunk~2 &&
181 git update-ref -d refs/remotes/stunk &&
182 git config --unset svn-remote.svn.fetch stunk &&
183 mkdir -p "$GIT_DIR"/svn/refs/remotes/flunk@18 &&
184 rev_map=$(cd "$GIT_DIR"/svn/refs/remotes/stunk && ls .rev_map*) &&
185 dd if="$GIT_DIR"/svn/refs/remotes/stunk/$rev_map \
186 of="$GIT_DIR"/svn/refs/remotes/flunk@18/$rev_map bs=24 count=1 &&
187 rm -rf "$GIT_DIR"/svn/refs/remotes/stunk &&
188 git svn init --minimize-url -i flunk "$svnrepo"/flunk &&
189 git svn fetch -i flunk &&
190 git svn init --minimize-url -i stunk "$svnrepo"/stunk &&
191 git svn fetch -i stunk &&
192 git svn init --minimize-url -i flunked "$svnrepo"/flunked &&
193 git svn fetch -i flunked
194 test "`git rev-parse --verify refs/remotes/flunk@18`" \
195 = "`git rev-parse --verify refs/remotes/stunk`" &&
196 test "`git rev-parse --verify refs/remotes/flunk~1`" \
197 = "`git rev-parse --verify refs/remotes/stunk`" &&
198 test "`git rev-parse --verify refs/remotes/flunked~1`" \
199 = "`git rev-parse --verify refs/remotes/stunk~1`"
202 test_expect_success "track multi-parent paths" '
203 svn_cmd cp -m "resurrect /glob" "$svnrepo"/r9270 "$svnrepo"/glob &&
204 git svn multi-fetch &&
205 test `git cat-file commit refs/remotes/glob | \
206 grep "^parent " | wc -l` -eq 2
209 test_expect_success "multi-fetch continues to work" "
210 git svn multi-fetch
213 test_expect_success "multi-fetch works off a 'clean' repository" '
214 rm -r "$GIT_DIR/svn" "$GIT_DIR/refs/remotes" "$GIT_DIR/logs" &&
215 mkdir "$GIT_DIR/svn" &&
216 git svn multi-fetch
219 test_debug 'gitk --all &'
221 test_done