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