test-lib: quiet down init-db output for tests
[git.git] / t / t9100-git-svn-basic.sh
blobc22fe47213a8fccbb954aef4b175d2ea1a920e16
1 #!/bin/sh
3 # Copyright (c) 2006 Eric Wong
6 test_description='git-svn basic tests'
7 GIT_SVN_LC_ALL=$LC_ALL
9 case "$LC_ALL" in
10 *.UTF-8)
11 have_utf8=t
14 have_utf8=
16 esac
18 . ./lib-git-svn.sh
20 echo 'define NO_SVN_TESTS to skip git-svn tests'
22 test_expect_success \
23 'initialize git-svn' "
24 mkdir import &&
25 cd import &&
26 echo foo > foo &&
27 if test -z '$NO_SYMLINK'
28 then
29 ln -s foo foo.link
31 mkdir -p dir/a/b/c/d/e &&
32 echo 'deep dir' > dir/a/b/c/d/e/file &&
33 mkdir bar &&
34 echo 'zzz' > bar/zzz &&
35 echo '#!/bin/sh' > exec.sh &&
36 chmod +x exec.sh &&
37 svn import -m 'import for git-svn' . $svnrepo >/dev/null &&
38 cd .. &&
39 rm -rf import &&
40 git-svn init $svnrepo"
42 test_expect_success \
43 'import an SVN revision into git' \
44 'git-svn fetch'
46 test_expect_success "checkout from svn" "svn co $svnrepo '$SVN_TREE'"
48 name='try a deep --rmdir with a commit'
49 test_expect_success "$name" "
50 git checkout -f -b mybranch remotes/git-svn &&
51 mv dir/a/b/c/d/e/file dir/file &&
52 cp dir/file file &&
53 git update-index --add --remove dir/a/b/c/d/e/file dir/file file &&
54 git commit -m '$name' &&
55 git-svn set-tree --find-copies-harder --rmdir \
56 remotes/git-svn..mybranch &&
57 svn up '$SVN_TREE' &&
58 test -d '$SVN_TREE'/dir && test ! -d '$SVN_TREE'/dir/a"
61 name='detect node change from file to directory #1'
62 test_expect_failure "$name" "
63 mkdir dir/new_file &&
64 mv dir/file dir/new_file/file &&
65 mv dir/new_file dir/file &&
66 git update-index --remove dir/file &&
67 git update-index --add dir/file/file &&
68 git commit -m '$name' &&
69 git-svn set-tree --find-copies-harder --rmdir \
70 remotes/git-svn..mybranch" || true
73 name='detect node change from directory to file #1'
74 test_expect_failure "$name" "
75 rm -rf dir '$GIT_DIR'/index &&
76 git checkout -f -b mybranch2 remotes/git-svn &&
77 mv bar/zzz zzz &&
78 rm -rf bar &&
79 mv zzz bar &&
80 git update-index --remove -- bar/zzz &&
81 git update-index --add -- bar &&
82 git commit -m '$name' &&
83 git-svn set-tree --find-copies-harder --rmdir \
84 remotes/git-svn..mybranch2" || true
87 name='detect node change from file to directory #2'
88 test_expect_failure "$name" "
89 rm -f '$GIT_DIR'/index &&
90 git checkout -f -b mybranch3 remotes/git-svn &&
91 rm bar/zzz &&
92 git-update-index --remove bar/zzz &&
93 mkdir bar/zzz &&
94 echo yyy > bar/zzz/yyy &&
95 git-update-index --add bar/zzz/yyy &&
96 git commit -m '$name' &&
97 git-svn set-tree --find-copies-harder --rmdir \
98 remotes/git-svn..mybranch3" || true
101 name='detect node change from directory to file #2'
102 test_expect_failure "$name" "
103 rm -f '$GIT_DIR'/index &&
104 git checkout -f -b mybranch4 remotes/git-svn &&
105 rm -rf dir &&
106 git update-index --remove -- dir/file &&
107 touch dir &&
108 echo asdf > dir &&
109 git update-index --add -- dir &&
110 git commit -m '$name' &&
111 git-svn set-tree --find-copies-harder --rmdir \
112 remotes/git-svn..mybranch4" || true
115 name='remove executable bit from a file'
116 test_expect_success "$name" "
117 rm -f '$GIT_DIR'/index &&
118 git checkout -f -b mybranch5 remotes/git-svn &&
119 chmod -x exec.sh &&
120 git update-index exec.sh &&
121 git commit -m '$name' &&
122 git-svn set-tree --find-copies-harder --rmdir \
123 remotes/git-svn..mybranch5 &&
124 svn up '$SVN_TREE' &&
125 test ! -x '$SVN_TREE'/exec.sh"
128 name='add executable bit back file'
129 test_expect_success "$name" "
130 chmod +x exec.sh &&
131 git update-index exec.sh &&
132 git commit -m '$name' &&
133 git-svn set-tree --find-copies-harder --rmdir \
134 remotes/git-svn..mybranch5 &&
135 svn up '$SVN_TREE' &&
136 test -x '$SVN_TREE'/exec.sh"
139 if test -z "$NO_SYMLINK"
140 then
141 name='executable file becomes a symlink to bar/zzz (file)'
143 test_expect_success "$name" "
144 rm exec.sh &&
145 ln -s bar/zzz exec.sh &&
146 git update-index exec.sh &&
147 git commit -m '$name' &&
148 git-svn set-tree --find-copies-harder --rmdir \
149 remotes/git-svn..mybranch5 &&
150 svn up '$SVN_TREE' &&
151 test -L '$SVN_TREE'/exec.sh"
153 name='new symlink is added to a file that was also just made executable'
155 test_expect_success "$name" "
156 chmod +x bar/zzz &&
157 ln -s bar/zzz exec-2.sh &&
158 git update-index --add bar/zzz exec-2.sh &&
159 git commit -m '$name' &&
160 git-svn set-tree --find-copies-harder --rmdir \
161 remotes/git-svn..mybranch5 &&
162 svn up '$SVN_TREE' &&
163 test -x '$SVN_TREE'/bar/zzz &&
164 test -L '$SVN_TREE'/exec-2.sh"
166 name='modify a symlink to become a file'
167 test_expect_success "$name" "
168 echo git help > help || true &&
169 rm exec-2.sh &&
170 cp help exec-2.sh &&
171 git update-index exec-2.sh &&
172 git commit -m '$name' &&
173 git-svn set-tree --find-copies-harder --rmdir \
174 remotes/git-svn..mybranch5 &&
175 svn up '$SVN_TREE' &&
176 test -f '$SVN_TREE'/exec-2.sh &&
177 test ! -L '$SVN_TREE'/exec-2.sh &&
178 diff -u help $SVN_TREE/exec-2.sh"
182 if test "$have_utf8" = t
183 then
184 name="commit with UTF-8 message: locale: $GIT_SVN_LC_ALL"
185 LC_ALL="$GIT_SVN_LC_ALL"
186 export LC_ALL
187 test_expect_success "$name" "
188 echo '# hello' >> exec-2.sh &&
189 git update-index exec-2.sh &&
190 git commit -m 'éï∏' &&
191 git-svn set-tree HEAD"
192 unset LC_ALL
193 else
194 echo "UTF-8 locale not set, test skipped ($GIT_SVN_LC_ALL)"
197 name='test fetch functionality (svn => git) with alternate GIT_SVN_ID'
198 GIT_SVN_ID=alt
199 export GIT_SVN_ID
200 test_expect_success "$name" \
201 "git-svn init $svnrepo && git-svn fetch &&
202 git-rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a &&
203 git-rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b &&
204 diff -u a b"
206 if test -n "$NO_SYMLINK"
207 then
208 test_done
209 exit 0
212 name='check imported tree checksums expected tree checksums'
213 rm -f expected
214 if test "$have_utf8" = t
215 then
216 echo tree bf522353586b1b883488f2bc73dab0d9f774b9a9 > expected
218 cat >> expected <<\EOF
219 tree 83654bb36f019ae4fe77a0171f81075972087624
220 tree 031b8d557afc6fea52894eaebb45bec52f1ba6d1
221 tree 0b094cbff17168f24c302e297f55bfac65eb8bd3
222 tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
223 tree 56a30b966619b863674f5978696f4a3594f2fca9
224 tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
225 tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4
228 echo tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 >> expected
230 test_expect_success "$name" "diff -u a expected"
232 test_done