]>
Commit | Line | Data |
---|---|---|
96a40b27 EW |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Eric Wong | |
4 | # | |
5 | ||
60d02ccc | 6 | test_description='git-svn basic tests' |
7a97de4e | 7 | GIT_SVN_LC_ALL=$LC_ALL |
dc62e25c EW |
8 | |
9 | case "$LC_ALL" in | |
10 | *.UTF-8) | |
11 | have_utf8=t | |
12 | ;; | |
13 | *) | |
14 | have_utf8= | |
15 | ;; | |
16 | esac | |
17 | ||
36f5b1f0 | 18 | . ./lib-git-svn.sh |
96a40b27 | 19 | |
60d02ccc EW |
20 | echo 'define NO_SVN_TESTS to skip git-svn tests' |
21 | ||
96a40b27 | 22 | test_expect_success \ |
39ed7c18 EW |
23 | 'initialize git-svn' " |
24 | mkdir import && | |
25 | cd import && | |
26 | echo foo > foo && | |
5bd3870c | 27 | ln -s foo foo.link |
39ed7c18 EW |
28 | mkdir -p dir/a/b/c/d/e && |
29 | echo 'deep dir' > dir/a/b/c/d/e/file && | |
30 | mkdir bar && | |
31 | echo 'zzz' > bar/zzz && | |
32 | echo '#!/bin/sh' > exec.sh && | |
33 | chmod +x exec.sh && | |
34 | svn import -m 'import for git-svn' . $svnrepo >/dev/null && | |
35 | cd .. && | |
36 | rm -rf import && | |
37 | git-svn init $svnrepo" | |
96a40b27 EW |
38 | |
39 | test_expect_success \ | |
40 | 'import an SVN revision into git' \ | |
41 | 'git-svn fetch' | |
42 | ||
39ed7c18 | 43 | test_expect_success "checkout from svn" "svn co $svnrepo '$SVN_TREE'" |
96a40b27 EW |
44 | |
45 | name='try a deep --rmdir with a commit' | |
39ed7c18 EW |
46 | test_expect_success "$name" " |
47 | git checkout -f -b mybranch remotes/git-svn && | |
48 | mv dir/a/b/c/d/e/file dir/file && | |
49 | cp dir/file file && | |
50 | git update-index --add --remove dir/a/b/c/d/e/file dir/file file && | |
51 | git commit -m '$name' && | |
52 | git-svn set-tree --find-copies-harder --rmdir \ | |
53 | remotes/git-svn..mybranch && | |
54 | svn up '$SVN_TREE' && | |
55 | test -d '$SVN_TREE'/dir && test ! -d '$SVN_TREE'/dir/a" | |
96a40b27 EW |
56 | |
57 | ||
58 | name='detect node change from file to directory #1' | |
41ac414e | 59 | test_expect_success "$name" " |
39ed7c18 EW |
60 | mkdir dir/new_file && |
61 | mv dir/file dir/new_file/file && | |
62 | mv dir/new_file dir/file && | |
63 | git update-index --remove dir/file && | |
64 | git update-index --add dir/file/file && | |
41ac414e JH |
65 | git commit -m '$name' && |
66 | ! git-svn set-tree --find-copies-harder --rmdir \ | |
39ed7c18 | 67 | remotes/git-svn..mybranch" || true |
96a40b27 EW |
68 | |
69 | ||
70 | name='detect node change from directory to file #1' | |
41ac414e | 71 | test_expect_success "$name" " |
39ed7c18 EW |
72 | rm -rf dir '$GIT_DIR'/index && |
73 | git checkout -f -b mybranch2 remotes/git-svn && | |
74 | mv bar/zzz zzz && | |
75 | rm -rf bar && | |
76 | mv zzz bar && | |
77 | git update-index --remove -- bar/zzz && | |
78 | git update-index --add -- bar && | |
79 | git commit -m '$name' && | |
41ac414e | 80 | ! git-svn set-tree --find-copies-harder --rmdir \ |
39ed7c18 | 81 | remotes/git-svn..mybranch2" || true |
96a40b27 EW |
82 | |
83 | ||
84 | name='detect node change from file to directory #2' | |
41ac414e | 85 | test_expect_success "$name" " |
39ed7c18 EW |
86 | rm -f '$GIT_DIR'/index && |
87 | git checkout -f -b mybranch3 remotes/git-svn && | |
88 | rm bar/zzz && | |
5be60078 | 89 | git update-index --remove bar/zzz && |
39ed7c18 EW |
90 | mkdir bar/zzz && |
91 | echo yyy > bar/zzz/yyy && | |
5be60078 | 92 | git update-index --add bar/zzz/yyy && |
39ed7c18 | 93 | git commit -m '$name' && |
41ac414e | 94 | ! git-svn set-tree --find-copies-harder --rmdir \ |
39ed7c18 | 95 | remotes/git-svn..mybranch3" || true |
96a40b27 EW |
96 | |
97 | ||
98 | name='detect node change from directory to file #2' | |
41ac414e | 99 | test_expect_success "$name" " |
39ed7c18 EW |
100 | rm -f '$GIT_DIR'/index && |
101 | git checkout -f -b mybranch4 remotes/git-svn && | |
102 | rm -rf dir && | |
103 | git update-index --remove -- dir/file && | |
104 | touch dir && | |
105 | echo asdf > dir && | |
106 | git update-index --add -- dir && | |
107 | git commit -m '$name' && | |
41ac414e | 108 | ! git-svn set-tree --find-copies-harder --rmdir \ |
39ed7c18 | 109 | remotes/git-svn..mybranch4" || true |
96a40b27 EW |
110 | |
111 | ||
112 | name='remove executable bit from a file' | |
39ed7c18 EW |
113 | test_expect_success "$name" " |
114 | rm -f '$GIT_DIR'/index && | |
115 | git checkout -f -b mybranch5 remotes/git-svn && | |
116 | chmod -x exec.sh && | |
117 | git update-index exec.sh && | |
118 | git commit -m '$name' && | |
119 | git-svn set-tree --find-copies-harder --rmdir \ | |
120 | remotes/git-svn..mybranch5 && | |
121 | svn up '$SVN_TREE' && | |
122 | test ! -x '$SVN_TREE'/exec.sh" | |
96a40b27 EW |
123 | |
124 | ||
125 | name='add executable bit back file' | |
39ed7c18 EW |
126 | test_expect_success "$name" " |
127 | chmod +x exec.sh && | |
128 | git update-index exec.sh && | |
129 | git commit -m '$name' && | |
130 | git-svn set-tree --find-copies-harder --rmdir \ | |
131 | remotes/git-svn..mybranch5 && | |
132 | svn up '$SVN_TREE' && | |
133 | test -x '$SVN_TREE'/exec.sh" | |
96a40b27 EW |
134 | |
135 | ||
5bd3870c EW |
136 | name='executable file becomes a symlink to bar/zzz (file)' |
137 | test_expect_success "$name" " | |
138 | rm exec.sh && | |
139 | ln -s bar/zzz exec.sh && | |
140 | git update-index exec.sh && | |
141 | git commit -m '$name' && | |
142 | git-svn set-tree --find-copies-harder --rmdir \ | |
143 | remotes/git-svn..mybranch5 && | |
144 | svn up '$SVN_TREE' && | |
145 | test -L '$SVN_TREE'/exec.sh" | |
0e8a002c | 146 | |
5bd3870c | 147 | name='new symlink is added to a file that was also just made executable' |
0e8a002c | 148 | |
5bd3870c EW |
149 | test_expect_success "$name" " |
150 | chmod +x bar/zzz && | |
151 | ln -s bar/zzz exec-2.sh && | |
152 | git update-index --add bar/zzz exec-2.sh && | |
153 | git commit -m '$name' && | |
154 | git-svn set-tree --find-copies-harder --rmdir \ | |
155 | remotes/git-svn..mybranch5 && | |
156 | svn up '$SVN_TREE' && | |
157 | test -x '$SVN_TREE'/bar/zzz && | |
158 | test -L '$SVN_TREE'/exec-2.sh" | |
96a40b27 | 159 | |
5bd3870c EW |
160 | name='modify a symlink to become a file' |
161 | test_expect_success "$name" " | |
162 | echo git help > help || true && | |
163 | rm exec-2.sh && | |
164 | cp help exec-2.sh && | |
165 | git update-index exec-2.sh && | |
166 | git commit -m '$name' && | |
167 | git-svn set-tree --find-copies-harder --rmdir \ | |
168 | remotes/git-svn..mybranch5 && | |
169 | svn up '$SVN_TREE' && | |
170 | test -f '$SVN_TREE'/exec-2.sh && | |
171 | test ! -L '$SVN_TREE'/exec-2.sh && | |
5bd74506 | 172 | git diff help $SVN_TREE/exec-2.sh" |
96a40b27 | 173 | |
dc62e25c | 174 | if test "$have_utf8" = t |
7a97de4e EW |
175 | then |
176 | name="commit with UTF-8 message: locale: $GIT_SVN_LC_ALL" | |
39ed7c18 EW |
177 | LC_ALL="$GIT_SVN_LC_ALL" |
178 | export LC_ALL | |
179 | test_expect_success "$name" " | |
180 | echo '# hello' >> exec-2.sh && | |
181 | git update-index exec-2.sh && | |
182 | git commit -m 'éï∏' && | |
183 | git-svn set-tree HEAD" | |
7a97de4e EW |
184 | unset LC_ALL |
185 | else | |
186 | echo "UTF-8 locale not set, test skipped ($GIT_SVN_LC_ALL)" | |
187 | fi | |
96a40b27 EW |
188 | |
189 | name='test fetch functionality (svn => git) with alternate GIT_SVN_ID' | |
190 | GIT_SVN_ID=alt | |
191 | export GIT_SVN_ID | |
192 | test_expect_success "$name" \ | |
2beb3cdd | 193 | "git-svn init $svnrepo && git-svn fetch && |
5be60078 JH |
194 | git rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a && |
195 | git rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b && | |
5bd74506 | 196 | git diff a b" |
96a40b27 | 197 | |
42d32870 | 198 | name='check imported tree checksums expected tree checksums' |
86f36379 | 199 | rm -f expected |
dc62e25c | 200 | if test "$have_utf8" = t |
86f36379 | 201 | then |
822a7d50 | 202 | echo tree bf522353586b1b883488f2bc73dab0d9f774b9a9 > expected |
86f36379 EW |
203 | fi |
204 | cat >> expected <<\EOF | |
822a7d50 | 205 | tree 83654bb36f019ae4fe77a0171f81075972087624 |
42d32870 EW |
206 | tree 031b8d557afc6fea52894eaebb45bec52f1ba6d1 |
207 | tree 0b094cbff17168f24c302e297f55bfac65eb8bd3 | |
208 | tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e | |
209 | tree 56a30b966619b863674f5978696f4a3594f2fca9 | |
210 | tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e | |
211 | tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4 | |
212 | EOF | |
e1516119 | 213 | |
5bd74506 | 214 | test_expect_success "$name" "git diff a expected" |
42d32870 | 215 | |
41ac414e | 216 | test_expect_success 'exit if remote refs are ambigious' " |
5be60078 | 217 | git config --add svn-remote.svn.fetch \ |
b805b44a | 218 | bar:refs/remotes/git-svn && |
41ac414e JH |
219 | ! git-svn migrate |
220 | " | |
e6434f87 | 221 | |
41ac414e | 222 | test_expect_success 'exit if init-ing a would clobber a URL' " |
e6434f87 EW |
223 | svnadmin create ${PWD}/svnrepo2 && |
224 | svn mkdir -m 'mkdir bar' ${svnrepo}2/bar && | |
5be60078 | 225 | git config --unset svn-remote.svn.fetch \ |
b805b44a | 226 | '^bar:refs/remotes/git-svn$' && |
41ac414e | 227 | ! git-svn init ${svnrepo}2/bar |
e6434f87 EW |
228 | " |
229 | ||
230 | test_expect_success \ | |
231 | 'init allows us to connect to another directory in the same repo' " | |
4a1bb4c3 | 232 | git-svn init --minimize-url -i bar $svnrepo/bar && |
ccb6b6f5 | 233 | git config --get svn-remote.svn.fetch \ |
e6434f87 | 234 | '^bar:refs/remotes/bar$' && |
ccb6b6f5 | 235 | git config --get svn-remote.svn.fetch \ |
e6434f87 | 236 | '^:refs/remotes/git-svn$' |
b805b44a EW |
237 | " |
238 | ||
d3a840dc EW |
239 | test_expect_success 'able to dcommit to a subdirectory' " |
240 | git-svn fetch -i bar && | |
241 | git checkout -b my-bar refs/remotes/bar && | |
242 | echo abc > d && | |
243 | git update-index --add d && | |
244 | git commit -m '/bar/d should be in the log' && | |
245 | git-svn dcommit -i bar && | |
246 | test -z \"\`git diff refs/heads/my-bar refs/remotes/bar\`\" && | |
247 | mkdir newdir && | |
248 | echo new > newdir/dir && | |
249 | git update-index --add newdir/dir && | |
250 | git commit -m 'add a new directory' && | |
251 | git-svn dcommit -i bar && | |
252 | test -z \"\`git diff refs/heads/my-bar refs/remotes/bar\`\" && | |
253 | echo foo >> newdir/dir && | |
254 | git update-index newdir/dir && | |
255 | git commit -m 'modify a file in new directory' && | |
256 | git-svn dcommit -i bar && | |
257 | test -z \"\`git diff refs/heads/my-bar refs/remotes/bar\`\" | |
258 | " | |
259 | ||
260 | test_expect_success 'able to set-tree to a subdirectory' " | |
261 | echo cba > d && | |
262 | git update-index d && | |
263 | git commit -m 'update /bar/d' && | |
264 | git-svn set-tree -i bar HEAD && | |
265 | test -z \"\`git diff refs/heads/my-bar refs/remotes/bar\`\" | |
266 | " | |
267 | ||
96a40b27 | 268 | test_done |