3 # Copyright (c) 2006 Eric Wong
6 test_description
='git-svn basic tests'
20 echo 'define NO_SVN_TESTS to skip git-svn tests'
23 'initialize git-svn' "
27 if test -z '$NO_SYMLINK'
31 mkdir -p dir/a/b/c/d/e &&
32 echo 'deep dir' > dir/a/b/c/d/e/file &&
34 echo 'zzz' > bar/zzz &&
35 echo '#!/bin/sh' > exec.sh &&
37 svn import -m 'import for git-svn' . $svnrepo >/dev/null &&
40 git-svn init $svnrepo"
43 'import an SVN revision into git' \
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 &&
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 &&
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" "
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 &&
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 &&
92 git-update-index --remove 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 &&
106 git update-index --remove -- dir/file &&
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 &&
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" "
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"
141 name
='executable file becomes a symlink to bar/zzz (file)'
143 test_expect_success
"$name" "
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" "
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 &&
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
184 name
="commit with UTF-8 message: locale: $GIT_SVN_LC_ALL"
185 LC_ALL
="$GIT_SVN_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"
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'
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 &&
206 if test -n "$NO_SYMLINK"
212 name
='check imported tree checksums expected tree checksums'
214 if test "$have_utf8" = t
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"