3 # Copyright (c) 2006 Eric Wong
6 test_description='git-svn basic tests'
20 echo 'define NO_SVN_TESTS to skip git-svn tests'
26 if test -z "$NO_SYMLINK"
30 mkdir -p dir/a/b/c/d/e
31 echo 'deep dir' > dir/a/b/c/d/e/file
34 echo '#!/bin/sh' > exec.sh
36 svn import -m 'import for git-svn' . "$svnrepo" >/dev/null
42 'initialize git-svn' \
43 "git-svn init $svnrepo"
46 'import an SVN revision into git' \
49 test_expect_success "checkout from svn" "svn co $svnrepo $SVN_TREE"
51 name='try a deep --rmdir with a commit'
52 git checkout -f -b mybranch remotes/git-svn
53 mv dir/a/b/c/d/e/file dir/file
55 git update-index --add --remove dir/a/b/c/d/e/file dir/file file
58 test_expect_success "$name" \
59 "git-svn set-tree --find-copies-harder --rmdir remotes/git-svn..mybranch &&
61 test -d $SVN_TREE/dir && test ! -d $SVN_TREE/dir/a"
64 name='detect node change from file to directory #1'
66 mv dir/file dir/new_file/file
67 mv dir/new_file dir/file
68 git update-index --remove dir/file
69 git update-index --add dir/file/file
72 test_expect_failure "$name" \
73 'git-svn set-tree --find-copies-harder --rmdir remotes/git-svn..mybranch' \
77 name='detect node change from directory to file #1'
78 rm -rf dir $GIT_DIR/index
79 git checkout -f -b mybranch2 remotes/git-svn
83 git update-index --remove -- bar/zzz
84 git update-index --add -- bar
87 test_expect_failure "$name" \
88 'git-svn set-tree --find-copies-harder --rmdir remotes/git-svn..mybranch2' \
92 name='detect node change from file to directory #2'
94 git checkout -f -b mybranch3 remotes/git-svn
96 git-update-index --remove bar/zzz
98 echo yyy > bar/zzz/yyy
99 git-update-index --add bar/zzz/yyy
100 git commit -m "$name"
102 test_expect_failure "$name" \
103 'git-svn set-tree --find-copies-harder --rmdir remotes/git-svn..mybranch3' \
107 name='detect node change from directory to file #2'
109 git checkout -f -b mybranch4 remotes/git-svn
111 git update-index --remove -- dir/file
114 git update-index --add -- dir
115 git commit -m "$name"
117 test_expect_failure "$name" \
118 'git-svn set-tree --find-copies-harder --rmdir remotes/git-svn..mybranch4' \
122 name='remove executable bit from a file'
124 git checkout -f -b mybranch5 remotes/git-svn
126 git update-index exec.sh
127 git commit -m "$name"
129 test_expect_success "$name" \
130 "git-svn set-tree --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
132 test ! -x $SVN_TREE/exec.sh"
135 name='add executable bit back file'
137 git update-index exec.sh
138 git commit -m "$name"
140 test_expect_success "$name" \
141 "git-svn set-tree --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
143 test -x $SVN_TREE/exec.sh"
147 if test -z "$NO_SYMLINK"
149 name='executable file becomes a symlink to bar/zzz (file)'
151 ln -s bar/zzz exec.sh
152 git update-index exec.sh
153 git commit -m "$name"
155 test_expect_success "$name" \
156 "git-svn set-tree --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
158 test -L $SVN_TREE/exec.sh"
160 name='new symlink is added to a file that was also just made executable'
162 ln -s bar/zzz exec-2.sh
163 git update-index --add bar/zzz exec-2.sh
164 git commit -m "$name"
166 test_expect_success "$name" \
167 "git-svn set-tree --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
169 test -x $SVN_TREE/bar/zzz &&
170 test -L $SVN_TREE/exec-2.sh"
172 name='modify a symlink to become a file'
173 echo git help > help || true
176 git update-index exec-2.sh
177 git commit -m "$name"
179 test_expect_success "$name" \
180 "git-svn set-tree --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
182 test -f $SVN_TREE/exec-2.sh &&
183 test ! -L $SVN_TREE/exec-2.sh &&
184 diff -u help $SVN_TREE/exec-2.sh"
188 if test "$have_utf8" = t
190 name="commit with UTF-8 message: locale: $GIT_SVN_LC_ALL"
191 echo '# hello' >> exec-2.sh
192 git update-index exec-2.sh
194 export LC_ALL="$GIT_SVN_LC_ALL"
195 test_expect_success "$name" "git-svn set-tree HEAD"
198 echo "UTF-8 locale not set, test skipped ($GIT_SVN_LC_ALL)"
201 name='test fetch functionality (svn => git) with alternate GIT_SVN_ID'
204 test_expect_success "$name" \
205 "git-svn init $svnrepo && git-svn fetch &&
206 git-rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a &&
207 git-rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b &&
210 if test -n "$NO_SYMLINK"
216 name='check imported tree checksums expected tree checksums'
218 if test "$have_utf8" = t
220 echo tree bf522353586b1b883488f2bc73dab0d9f774b9a9 > expected
222 cat >> expected <<\EOF
223 tree 83654bb36f019ae4fe77a0171f81075972087624
224 tree 031b8d557afc6fea52894eaebb45bec52f1ba6d1
225 tree 0b094cbff17168f24c302e297f55bfac65eb8bd3
226 tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
227 tree 56a30b966619b863674f5978696f4a3594f2fca9
228 tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
229 tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4
232 echo tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 >> expected
234 test_expect_success "$name" "diff -u a expected"