3 # Copyright (c) 2006 Eric Wong
6 test_description='git-svn tests'
24 if test -z "$NO_SYMLINK"
28 mkdir -p dir/a/b/c/d/e
29 echo 'deep dir' > dir/a/b/c/d/e/file
32 echo '#!/bin/sh' > exec.sh
34 svn import -m 'import for git-svn' . "$svnrepo" >/dev/null
40 'initialize git-svn' \
41 "git-svn init $svnrepo"
44 'import an SVN revision into git' \
47 test_expect_success "checkout from svn" "svn co $svnrepo $SVN_TREE"
49 name='try a deep --rmdir with a commit'
50 git checkout -f -b mybranch remotes/git-svn
51 mv dir/a/b/c/d/e/file dir/file
53 git update-index --add --remove dir/a/b/c/d/e/file dir/file file
56 test_expect_success "$name" \
57 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch &&
59 test -d $SVN_TREE/dir && test ! -d $SVN_TREE/dir/a"
62 name='detect node change from file to directory #1'
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
70 test_expect_failure "$name" \
71 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch' \
75 name='detect node change from directory to file #1'
76 rm -rf dir $GIT_DIR/index
77 git checkout -f -b mybranch2 remotes/git-svn
81 git update-index --remove -- bar/zzz
82 git update-index --add -- bar
85 test_expect_failure "$name" \
86 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch2' \
90 name='detect node change from file to directory #2'
92 git checkout -f -b mybranch3 remotes/git-svn
94 git-update-index --remove bar/zzz
96 echo yyy > bar/zzz/yyy
97 git-update-index --add bar/zzz/yyy
100 test_expect_failure "$name" \
101 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch3' \
105 name='detect node change from directory to file #2'
107 git checkout -f -b mybranch4 remotes/git-svn
109 git update-index --remove -- dir/file
112 git update-index --add -- dir
113 git commit -m "$name"
115 test_expect_failure "$name" \
116 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch4' \
120 name='remove executable bit from a file'
122 git checkout -f -b mybranch5 remotes/git-svn
124 git update-index exec.sh
125 git commit -m "$name"
127 test_expect_success "$name" \
128 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
130 test ! -x $SVN_TREE/exec.sh"
133 name='add executable bit back file'
135 git update-index exec.sh
136 git commit -m "$name"
138 test_expect_success "$name" \
139 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
141 test -x $SVN_TREE/exec.sh"
145 if test -z "$NO_SYMLINK"
147 name='executable file becomes a symlink to bar/zzz (file)'
149 ln -s bar/zzz exec.sh
150 git update-index exec.sh
151 git commit -m "$name"
153 test_expect_success "$name" \
154 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
156 test -L $SVN_TREE/exec.sh"
158 name='new symlink is added to a file that was also just made executable'
160 ln -s bar/zzz exec-2.sh
161 git update-index --add bar/zzz exec-2.sh
162 git commit -m "$name"
164 test_expect_success "$name" \
165 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
167 test -x $SVN_TREE/bar/zzz &&
168 test -L $SVN_TREE/exec-2.sh"
170 name='modify a symlink to become a file'
171 git help > help || true
174 git update-index exec-2.sh
175 git commit -m "$name"
177 test_expect_success "$name" \
178 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
180 test -f $SVN_TREE/exec-2.sh &&
181 test ! -L $SVN_TREE/exec-2.sh &&
182 diff -u help $SVN_TREE/exec-2.sh"
186 if test "$have_utf8" = t
188 name="commit with UTF-8 message: locale: $GIT_SVN_LC_ALL"
189 echo '# hello' >> exec-2.sh
190 git update-index exec-2.sh
192 export LC_ALL="$GIT_SVN_LC_ALL"
193 test_expect_success "$name" "git-svn commit HEAD"
196 echo "UTF-8 locale not set, test skipped ($GIT_SVN_LC_ALL)"
199 name='test fetch functionality (svn => git) with alternate GIT_SVN_ID'
202 test_expect_success "$name" \
203 "git-svn init $svnrepo && git-svn fetch &&
204 git-rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a &&
205 git-rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b &&
208 if test -n "$NO_SYMLINK"
214 name='check imported tree checksums expected tree checksums'
216 if test "$have_utf8" = t
218 echo tree f735671b89a7eb30cab1d8597de35bd4271ab813 > expected
220 cat >> expected <<\EOF
221 tree 4b9af72bb861eaed053854ec502cf7df72618f0f
222 tree 031b8d557afc6fea52894eaebb45bec52f1ba6d1
223 tree 0b094cbff17168f24c302e297f55bfac65eb8bd3
224 tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
225 tree 56a30b966619b863674f5978696f4a3594f2fca9
226 tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
227 tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4
229 test_expect_success "$name" "diff -u a expected"