git-svn: make the $GIT_DIR/svn/*/revs directory obsolete
[git/jnareb-git.git] / contrib / git-svn / t / t0000-contrib-git-svn.sh
blobf896e2c2a8587e0f2c5754f606d0885ccba6ca19
1 #!/bin/sh
3 # Copyright (c) 2006 Eric Wong
6 test_description='git-svn tests'
7 GIT_SVN_LC_ALL=$LC_ALL
8 . ./lib-git-svn.sh
10 mkdir import
11 cd import
13 echo foo > foo
14 ln -s foo foo.link
15 mkdir -p dir/a/b/c/d/e
16 echo 'deep dir' > dir/a/b/c/d/e/file
17 mkdir -p bar
18 echo 'zzz' > bar/zzz
19 echo '#!/bin/sh' > exec.sh
20 chmod +x exec.sh
21 svn import -m 'import for git-svn' . "$svnrepo" >/dev/null
23 cd ..
24 rm -rf import
26 test_expect_success \
27 'initialize git-svn' \
28 "git-svn init $svnrepo"
30 test_expect_success \
31 'import an SVN revision into git' \
32 'git-svn fetch'
34 test_expect_success "checkout from svn" "svn co $svnrepo $SVN_TREE"
36 name='try a deep --rmdir with a commit'
37 git checkout -f -b mybranch remotes/git-svn
38 mv dir/a/b/c/d/e/file dir/file
39 cp dir/file file
40 git update-index --add --remove dir/a/b/c/d/e/file dir/file file
41 git commit -m "$name"
43 test_expect_success "$name" \
44 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch &&
45 svn up $SVN_TREE &&
46 test -d $SVN_TREE/dir && test ! -d $SVN_TREE/dir/a"
49 name='detect node change from file to directory #1'
50 mkdir dir/new_file
51 mv dir/file dir/new_file/file
52 mv dir/new_file dir/file
53 git update-index --remove dir/file
54 git update-index --add dir/file/file
55 git commit -m "$name"
57 test_expect_failure "$name" \
58 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch' \
59 || true
62 name='detect node change from directory to file #1'
63 rm -rf dir $GIT_DIR/index
64 git checkout -f -b mybranch2 remotes/git-svn
65 mv bar/zzz zzz
66 rm -rf bar
67 mv zzz bar
68 git update-index --remove -- bar/zzz
69 git update-index --add -- bar
70 git commit -m "$name"
72 test_expect_failure "$name" \
73 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch2' \
74 || true
77 name='detect node change from file to directory #2'
78 rm -f $GIT_DIR/index
79 git checkout -f -b mybranch3 remotes/git-svn
80 rm bar/zzz
81 git-update-index --remove bar/zzz
82 mkdir bar/zzz
83 echo yyy > bar/zzz/yyy
84 git-update-index --add bar/zzz/yyy
85 git commit -m "$name"
87 test_expect_failure "$name" \
88 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch3' \
89 || true
92 name='detect node change from directory to file #2'
93 rm -f $GIT_DIR/index
94 git checkout -f -b mybranch4 remotes/git-svn
95 rm -rf dir
96 git update-index --remove -- dir/file
97 touch dir
98 echo asdf > dir
99 git update-index --add -- dir
100 git commit -m "$name"
102 test_expect_failure "$name" \
103 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch4' \
104 || true
107 name='remove executable bit from a file'
108 rm -f $GIT_DIR/index
109 git checkout -f -b mybranch5 remotes/git-svn
110 chmod -x exec.sh
111 git update-index exec.sh
112 git commit -m "$name"
114 test_expect_success "$name" \
115 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
116 svn up $SVN_TREE &&
117 test ! -x $SVN_TREE/exec.sh"
120 name='add executable bit back file'
121 chmod +x exec.sh
122 git update-index exec.sh
123 git commit -m "$name"
125 test_expect_success "$name" \
126 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
127 svn up $SVN_TREE &&
128 test -x $SVN_TREE/exec.sh"
132 name='executable file becomes a symlink to bar/zzz (file)'
133 rm exec.sh
134 ln -s bar/zzz exec.sh
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 &&
140 svn up $SVN_TREE &&
141 test -L $SVN_TREE/exec.sh"
145 name='new symlink is added to a file that was also just made executable'
146 chmod +x bar/zzz
147 ln -s bar/zzz exec-2.sh
148 git update-index --add bar/zzz exec-2.sh
149 git commit -m "$name"
151 test_expect_success "$name" \
152 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
153 svn up $SVN_TREE &&
154 test -x $SVN_TREE/bar/zzz &&
155 test -L $SVN_TREE/exec-2.sh"
159 name='modify a symlink to become a file'
160 git help > help || true
161 rm exec-2.sh
162 cp help exec-2.sh
163 git update-index exec-2.sh
164 git commit -m "$name"
166 test_expect_success "$name" \
167 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
168 svn up $SVN_TREE &&
169 test -f $SVN_TREE/exec-2.sh &&
170 test ! -L $SVN_TREE/exec-2.sh &&
171 diff -u help $SVN_TREE/exec-2.sh"
174 if test -n "$GIT_SVN_LC_ALL" && echo $GIT_SVN_LC_ALL | grep -q '\.UTF-8$'
175 then
176 name="commit with UTF-8 message: locale: $GIT_SVN_LC_ALL"
177 echo '# hello' >> exec-2.sh
178 git update-index exec-2.sh
179 git commit -m 'éï∏'
180 export LC_ALL="$GIT_SVN_LC_ALL"
181 test_expect_success "$name" "git-svn commit HEAD"
182 unset LC_ALL
183 else
184 echo "UTF-8 locale not set, test skipped ($GIT_SVN_LC_ALL)"
187 name='test fetch functionality (svn => git) with alternate GIT_SVN_ID'
188 GIT_SVN_ID=alt
189 export GIT_SVN_ID
190 test_expect_success "$name" \
191 "git-svn init $svnrepo && git-svn fetch &&
192 git-rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a &&
193 git-rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b &&
194 diff -u a b"
196 name='check imported tree checksums expected tree checksums'
197 cat > expected <<\EOF
198 tree f735671b89a7eb30cab1d8597de35bd4271ab813
199 tree 4b9af72bb861eaed053854ec502cf7df72618f0f
200 tree 031b8d557afc6fea52894eaebb45bec52f1ba6d1
201 tree 0b094cbff17168f24c302e297f55bfac65eb8bd3
202 tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
203 tree 56a30b966619b863674f5978696f4a3594f2fca9
204 tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
205 tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4
207 test_expect_success "$name" "diff -u a expected"
209 test_done