]>
Commit | Line | Data |
---|---|---|
96a40b27 EW |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Eric Wong | |
4 | # | |
5 | ||
96a40b27 | 6 | test_description='git-svn tests' |
7a97de4e | 7 | GIT_SVN_LC_ALL=$LC_ALL |
dc62e25c EW |
8 | |
9 | case "$LC_ALL" in | |
10 | *.UTF-8) | |
11 | have_utf8=t | |
12 | ;; | |
13 | *) | |
14 | have_utf8= | |
15 | ;; | |
16 | esac | |
17 | ||
36f5b1f0 | 18 | . ./lib-git-svn.sh |
96a40b27 EW |
19 | |
20 | mkdir import | |
96a40b27 EW |
21 | cd import |
22 | ||
23 | echo foo > foo | |
0e8a002c EW |
24 | if test -z "$NO_SYMLINK" |
25 | then | |
26 | ln -s foo foo.link | |
27 | fi | |
96a40b27 EW |
28 | mkdir -p dir/a/b/c/d/e |
29 | echo 'deep dir' > dir/a/b/c/d/e/file | |
30 | mkdir -p bar | |
31 | echo 'zzz' > bar/zzz | |
32 | echo '#!/bin/sh' > exec.sh | |
33 | chmod +x exec.sh | |
36f5b1f0 | 34 | svn import -m 'import for git-svn' . "$svnrepo" >/dev/null |
96a40b27 EW |
35 | |
36 | cd .. | |
96a40b27 EW |
37 | rm -rf import |
38 | ||
39 | test_expect_success \ | |
40 | 'initialize git-svn' \ | |
41 | "git-svn init $svnrepo" | |
42 | ||
43 | test_expect_success \ | |
44 | 'import an SVN revision into git' \ | |
45 | 'git-svn fetch' | |
46 | ||
a5e0cedc | 47 | test_expect_success "checkout from svn" "svn co $svnrepo $SVN_TREE" |
96a40b27 EW |
48 | |
49 | name='try a deep --rmdir with a commit' | |
c7162c1d | 50 | git checkout -f -b mybranch remotes/git-svn |
96a40b27 EW |
51 | mv dir/a/b/c/d/e/file dir/file |
52 | cp dir/file file | |
53 | git update-index --add --remove dir/a/b/c/d/e/file dir/file file | |
54 | git commit -m "$name" | |
55 | ||
56 | test_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 | ||
62 | name='detect node change from file to directory #1' | |
63 | mkdir dir/new_file | |
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 | ||
a5e0cedc | 70 | test_expect_failure "$name" \ |
2beb3cdd | 71 | 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch' \ |
96a40b27 EW |
72 | || true |
73 | ||
74 | ||
75 | name='detect node change from directory to file #1' | |
76 | rm -rf dir $GIT_DIR/index | |
c7162c1d | 77 | git checkout -f -b mybranch2 remotes/git-svn |
96a40b27 EW |
78 | mv bar/zzz zzz |
79 | rm -rf bar | |
80 | mv zzz bar | |
81 | git update-index --remove -- bar/zzz | |
82 | git update-index --add -- bar | |
83 | git commit -m "$name" | |
84 | ||
a5e0cedc | 85 | test_expect_failure "$name" \ |
2beb3cdd | 86 | 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch2' \ |
96a40b27 EW |
87 | || true |
88 | ||
89 | ||
90 | name='detect node change from file to directory #2' | |
91 | rm -f $GIT_DIR/index | |
c7162c1d | 92 | git checkout -f -b mybranch3 remotes/git-svn |
96a40b27 EW |
93 | rm bar/zzz |
94 | git-update-index --remove bar/zzz | |
95 | mkdir bar/zzz | |
96 | echo yyy > bar/zzz/yyy | |
97 | git-update-index --add bar/zzz/yyy | |
98 | git commit -m "$name" | |
99 | ||
a5e0cedc | 100 | test_expect_failure "$name" \ |
2beb3cdd | 101 | 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch3' \ |
96a40b27 EW |
102 | || true |
103 | ||
104 | ||
105 | name='detect node change from directory to file #2' | |
106 | rm -f $GIT_DIR/index | |
c7162c1d | 107 | git checkout -f -b mybranch4 remotes/git-svn |
96a40b27 EW |
108 | rm -rf dir |
109 | git update-index --remove -- dir/file | |
110 | touch dir | |
111 | echo asdf > dir | |
112 | git update-index --add -- dir | |
113 | git commit -m "$name" | |
114 | ||
a5e0cedc | 115 | test_expect_failure "$name" \ |
2beb3cdd | 116 | 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch4' \ |
96a40b27 EW |
117 | || true |
118 | ||
119 | ||
120 | name='remove executable bit from a file' | |
121 | rm -f $GIT_DIR/index | |
c7162c1d | 122 | git checkout -f -b mybranch5 remotes/git-svn |
96a40b27 EW |
123 | chmod -x exec.sh |
124 | git update-index exec.sh | |
125 | git commit -m "$name" | |
126 | ||
127 | test_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 | ||
133 | name='add executable bit back file' | |
134 | chmod +x exec.sh | |
135 | git update-index exec.sh | |
136 | git commit -m "$name" | |
137 | ||
138 | test_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 |
145 | if test -z "$NO_SYMLINK" |
146 | then | |
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" | |
183 | fi | |
96a40b27 EW |
184 | |
185 | ||
dc62e25c | 186 | if test "$have_utf8" = t |
7a97de4e EW |
187 | then |
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 | |
195 | else | |
196 | echo "UTF-8 locale not set, test skipped ($GIT_SVN_LC_ALL)" | |
197 | fi | |
96a40b27 EW |
198 | |
199 | name='test fetch functionality (svn => git) with alternate GIT_SVN_ID' | |
200 | GIT_SVN_ID=alt | |
201 | export GIT_SVN_ID | |
202 | test_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 |
208 | if test -n "$NO_SYMLINK" |
209 | then | |
210 | test_done | |
211 | exit 0 | |
212 | fi | |
213 | ||
42d32870 | 214 | name='check imported tree checksums expected tree checksums' |
86f36379 | 215 | rm -f expected |
dc62e25c | 216 | if test "$have_utf8" = t |
86f36379 EW |
217 | then |
218 | echo tree f735671b89a7eb30cab1d8597de35bd4271ab813 > expected | |
219 | fi | |
220 | cat >> expected <<\EOF | |
42d32870 EW |
221 | tree 4b9af72bb861eaed053854ec502cf7df72618f0f |
222 | tree 031b8d557afc6fea52894eaebb45bec52f1ba6d1 | |
223 | tree 0b094cbff17168f24c302e297f55bfac65eb8bd3 | |
224 | tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e | |
225 | tree 56a30b966619b863674f5978696f4a3594f2fca9 | |
226 | tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e | |
227 | tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4 | |
228 | EOF | |
229 | test_expect_success "$name" "diff -u a expected" | |
230 | ||
96a40b27 EW |
231 | test_done |
232 |