]> git.ipfire.org Git - thirdparty/git.git/blame - t/t9100-git-svn-basic.sh
git-svn: migrate out of contrib
[thirdparty/git.git] / t / t9100-git-svn-basic.sh
CommitLineData
96a40b27
EW
1#!/bin/sh
2#
3# Copyright (c) 2006 Eric Wong
4#
5
60d02ccc 6test_description='git-svn basic tests'
7a97de4e 7GIT_SVN_LC_ALL=$LC_ALL
dc62e25c
EW
8
9case "$LC_ALL" in
10*.UTF-8)
11 have_utf8=t
12 ;;
13*)
14 have_utf8=
15 ;;
16esac
17
36f5b1f0 18. ./lib-git-svn.sh
96a40b27 19
60d02ccc
EW
20echo 'define NO_SVN_TESTS to skip git-svn tests'
21
96a40b27 22mkdir import
96a40b27
EW
23cd import
24
25echo foo > foo
0e8a002c
EW
26if test -z "$NO_SYMLINK"
27then
28 ln -s foo foo.link
29fi
96a40b27
EW
30mkdir -p dir/a/b/c/d/e
31echo 'deep dir' > dir/a/b/c/d/e/file
32mkdir -p bar
33echo 'zzz' > bar/zzz
34echo '#!/bin/sh' > exec.sh
35chmod +x exec.sh
36f5b1f0 36svn import -m 'import for git-svn' . "$svnrepo" >/dev/null
96a40b27
EW
37
38cd ..
96a40b27
EW
39rm -rf import
40
41test_expect_success \
42 'initialize git-svn' \
43 "git-svn init $svnrepo"
44
45test_expect_success \
46 'import an SVN revision into git' \
47 'git-svn fetch'
48
a5e0cedc 49test_expect_success "checkout from svn" "svn co $svnrepo $SVN_TREE"
96a40b27
EW
50
51name='try a deep --rmdir with a commit'
c7162c1d 52git checkout -f -b mybranch remotes/git-svn
96a40b27
EW
53mv dir/a/b/c/d/e/file dir/file
54cp dir/file file
55git update-index --add --remove dir/a/b/c/d/e/file dir/file file
56git commit -m "$name"
57
58test_expect_success "$name" \
2beb3cdd 59 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch &&
a5e0cedc 60 svn up $SVN_TREE &&
96a40b27
EW
61 test -d $SVN_TREE/dir && test ! -d $SVN_TREE/dir/a"
62
63
64name='detect node change from file to directory #1'
65mkdir dir/new_file
66mv dir/file dir/new_file/file
67mv dir/new_file dir/file
68git update-index --remove dir/file
69git update-index --add dir/file/file
70git commit -m "$name"
71
a5e0cedc 72test_expect_failure "$name" \
2beb3cdd 73 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch' \
96a40b27
EW
74 || true
75
76
77name='detect node change from directory to file #1'
78rm -rf dir $GIT_DIR/index
c7162c1d 79git checkout -f -b mybranch2 remotes/git-svn
96a40b27
EW
80mv bar/zzz zzz
81rm -rf bar
82mv zzz bar
83git update-index --remove -- bar/zzz
84git update-index --add -- bar
85git commit -m "$name"
86
a5e0cedc 87test_expect_failure "$name" \
2beb3cdd 88 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch2' \
96a40b27
EW
89 || true
90
91
92name='detect node change from file to directory #2'
93rm -f $GIT_DIR/index
c7162c1d 94git checkout -f -b mybranch3 remotes/git-svn
96a40b27
EW
95rm bar/zzz
96git-update-index --remove bar/zzz
97mkdir bar/zzz
98echo yyy > bar/zzz/yyy
99git-update-index --add bar/zzz/yyy
100git commit -m "$name"
101
a5e0cedc 102test_expect_failure "$name" \
2beb3cdd 103 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch3' \
96a40b27
EW
104 || true
105
106
107name='detect node change from directory to file #2'
108rm -f $GIT_DIR/index
c7162c1d 109git checkout -f -b mybranch4 remotes/git-svn
96a40b27
EW
110rm -rf dir
111git update-index --remove -- dir/file
112touch dir
113echo asdf > dir
114git update-index --add -- dir
115git commit -m "$name"
116
a5e0cedc 117test_expect_failure "$name" \
2beb3cdd 118 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch4' \
96a40b27
EW
119 || true
120
121
122name='remove executable bit from a file'
123rm -f $GIT_DIR/index
c7162c1d 124git checkout -f -b mybranch5 remotes/git-svn
96a40b27
EW
125chmod -x exec.sh
126git update-index exec.sh
127git commit -m "$name"
128
129test_expect_success "$name" \
2beb3cdd 130 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
a5e0cedc 131 svn up $SVN_TREE &&
96a40b27
EW
132 test ! -x $SVN_TREE/exec.sh"
133
134
135name='add executable bit back file'
136chmod +x exec.sh
137git update-index exec.sh
138git commit -m "$name"
139
140test_expect_success "$name" \
2beb3cdd 141 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
a5e0cedc 142 svn up $SVN_TREE &&
96a40b27
EW
143 test -x $SVN_TREE/exec.sh"
144
145
146
0e8a002c
EW
147if test -z "$NO_SYMLINK"
148then
149 name='executable file becomes a symlink to bar/zzz (file)'
150 rm exec.sh
151 ln -s bar/zzz exec.sh
152 git update-index exec.sh
153 git commit -m "$name"
154
155 test_expect_success "$name" \
156 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
157 svn up $SVN_TREE &&
158 test -L $SVN_TREE/exec.sh"
159
160 name='new symlink is added to a file that was also just made executable'
161 chmod +x bar/zzz
162 ln -s bar/zzz exec-2.sh
163 git update-index --add bar/zzz exec-2.sh
164 git commit -m "$name"
165
166 test_expect_success "$name" \
167 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
168 svn up $SVN_TREE &&
169 test -x $SVN_TREE/bar/zzz &&
170 test -L $SVN_TREE/exec-2.sh"
171
172 name='modify a symlink to become a file'
173 git help > help || true
174 rm exec-2.sh
175 cp help exec-2.sh
176 git update-index exec-2.sh
177 git commit -m "$name"
178
179 test_expect_success "$name" \
180 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
181 svn up $SVN_TREE &&
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"
185fi
96a40b27
EW
186
187
dc62e25c 188if test "$have_utf8" = t
7a97de4e
EW
189then
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
193 git commit -m 'éï∏'
194 export LC_ALL="$GIT_SVN_LC_ALL"
195 test_expect_success "$name" "git-svn commit HEAD"
196 unset LC_ALL
197else
198 echo "UTF-8 locale not set, test skipped ($GIT_SVN_LC_ALL)"
199fi
96a40b27
EW
200
201name='test fetch functionality (svn => git) with alternate GIT_SVN_ID'
202GIT_SVN_ID=alt
203export GIT_SVN_ID
204test_expect_success "$name" \
2beb3cdd
EW
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 &&
96a40b27
EW
208 diff -u a b"
209
0e8a002c
EW
210if test -n "$NO_SYMLINK"
211then
212 test_done
213 exit 0
214fi
215
42d32870 216name='check imported tree checksums expected tree checksums'
86f36379 217rm -f expected
dc62e25c 218if test "$have_utf8" = t
86f36379
EW
219then
220 echo tree f735671b89a7eb30cab1d8597de35bd4271ab813 > expected
221fi
222cat >> expected <<\EOF
42d32870
EW
223tree 4b9af72bb861eaed053854ec502cf7df72618f0f
224tree 031b8d557afc6fea52894eaebb45bec52f1ba6d1
225tree 0b094cbff17168f24c302e297f55bfac65eb8bd3
226tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
227tree 56a30b966619b863674f5978696f4a3594f2fca9
228tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
229tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4
230EOF
231test_expect_success "$name" "diff -u a expected"
232
96a40b27
EW
233test_done
234