upload-pack: Improve error message when bad ref requested
[git/mingw.git] / t / t9119-git-svn-info.sh
blob5fb94fb3d61c2e26dcd448ac5106ec0f9a3a2283
1 #!/bin/sh
3 # Copyright (c) 2007 David D. Kilzer
5 test_description='git svn info'
7 . ./lib-git-svn.sh
9 # Tested with: svn, version 1.4.4 (r25188)
10 # Tested with: svn, version 1.6.[12345689]
11 v=`svn_cmd --version | sed -n -e 's/^svn, version \(1\.[0-9]*\.[0-9]*\).*$/\1/p'`
12 case $v in
13 1.[456].*)
16 skip_all="skipping svn-info test (SVN version: $v not supported)"
17 test_done
19 esac
21 ptouch() {
22 perl -w -e '
23 use strict;
24 use POSIX qw(mktime);
25 die "ptouch requires exactly 2 arguments" if @ARGV != 2;
26 my $text_last_updated = shift @ARGV;
27 my $git_file = shift @ARGV;
28 die "\"$git_file\" does not exist" if ! -e $git_file;
29 if ($text_last_updated
30 =~ /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/) {
31 my $mtime = mktime($6, $5, $4, $3, $2 - 1, $1 - 1900);
32 my $atime = $mtime;
33 utime $atime, $mtime, $git_file;
35 ' "`svn_cmd info $2 | grep '^Text Last Updated:'`" "$1"
38 quoted_svnrepo="$(echo $svnrepo | sed 's/ /%20/')"
40 test_expect_success 'setup repository and import' '
41 mkdir info &&
42 cd info &&
43 echo FIRST > A &&
44 echo one > file &&
45 ln -s file symlink-file &&
46 mkdir directory &&
47 touch directory/.placeholder &&
48 ln -s directory symlink-directory &&
49 svn_cmd import -m "initial" . "$svnrepo" &&
50 cd .. &&
51 svn_cmd co "$svnrepo" svnwc &&
52 cd svnwc &&
53 echo foo > foo &&
54 svn_cmd add foo &&
55 svn_cmd commit -m "change outside directory" &&
56 svn_cmd update &&
57 cd .. &&
58 mkdir gitwc &&
59 cd gitwc &&
60 git svn init "$svnrepo" &&
61 git svn fetch &&
62 cd .. &&
63 ptouch gitwc/file svnwc/file &&
64 ptouch gitwc/directory svnwc/directory &&
65 ptouch gitwc/symlink-file svnwc/symlink-file &&
66 ptouch gitwc/symlink-directory svnwc/symlink-directory
69 test_expect_success 'info' "
70 (cd svnwc; svn info) > expected.info &&
71 (cd gitwc; git svn info) > actual.info &&
72 test_cmp expected.info actual.info
75 test_expect_success 'info --url' '
76 test "$(cd gitwc; git svn info --url)" = "$quoted_svnrepo"
79 test_expect_success 'info .' "
80 (cd svnwc; svn info .) > expected.info-dot &&
81 (cd gitwc; git svn info .) > actual.info-dot &&
82 test_cmp expected.info-dot actual.info-dot
85 test_expect_success 'info --url .' '
86 test "$(cd gitwc; git svn info --url .)" = "$quoted_svnrepo"
89 test_expect_success 'info file' "
90 (cd svnwc; svn info file) > expected.info-file &&
91 (cd gitwc; git svn info file) > actual.info-file &&
92 test_cmp expected.info-file actual.info-file
95 test_expect_success 'info --url file' '
96 test "$(cd gitwc; git svn info --url file)" = "$quoted_svnrepo/file"
99 test_expect_success 'info directory' "
100 (cd svnwc; svn info directory) > expected.info-directory &&
101 (cd gitwc; git svn info directory) > actual.info-directory &&
102 test_cmp expected.info-directory actual.info-directory
105 test_expect_success 'info inside directory' "
106 (cd svnwc/directory; svn info) > expected.info-inside-directory &&
107 (cd gitwc/directory; git svn info) > actual.info-inside-directory &&
108 test_cmp expected.info-inside-directory actual.info-inside-directory
111 test_expect_success 'info --url directory' '
112 test "$(cd gitwc; git svn info --url directory)" = "$quoted_svnrepo/directory"
115 test_expect_success 'info symlink-file' "
116 (cd svnwc; svn info symlink-file) > expected.info-symlink-file &&
117 (cd gitwc; git svn info symlink-file) > actual.info-symlink-file &&
118 test_cmp expected.info-symlink-file actual.info-symlink-file
121 test_expect_success 'info --url symlink-file' '
122 test "$(cd gitwc; git svn info --url symlink-file)" \
123 = "$quoted_svnrepo/symlink-file"
126 test_expect_success 'info symlink-directory' "
127 (cd svnwc; svn info symlink-directory) \
128 > expected.info-symlink-directory &&
129 (cd gitwc; git svn info symlink-directory) \
130 > actual.info-symlink-directory &&
131 test_cmp expected.info-symlink-directory actual.info-symlink-directory
134 test_expect_success 'info --url symlink-directory' '
135 test "$(cd gitwc; git svn info --url symlink-directory)" \
136 = "$quoted_svnrepo/symlink-directory"
139 test_expect_success 'info added-file' "
140 echo two > gitwc/added-file &&
141 cd gitwc &&
142 git add added-file &&
143 cd .. &&
144 cp gitwc/added-file svnwc/added-file &&
145 ptouch gitwc/added-file svnwc/added-file &&
146 cd svnwc &&
147 svn_cmd add added-file > /dev/null &&
148 cd .. &&
149 (cd svnwc; svn info added-file) > expected.info-added-file &&
150 (cd gitwc; git svn info added-file) > actual.info-added-file &&
151 test_cmp expected.info-added-file actual.info-added-file
154 test_expect_success 'info --url added-file' '
155 test "$(cd gitwc; git svn info --url added-file)" \
156 = "$quoted_svnrepo/added-file"
159 test_expect_success 'info added-directory' "
160 mkdir gitwc/added-directory svnwc/added-directory &&
161 ptouch gitwc/added-directory svnwc/added-directory &&
162 touch gitwc/added-directory/.placeholder &&
163 cd svnwc &&
164 svn_cmd add added-directory > /dev/null &&
165 cd .. &&
166 cd gitwc &&
167 git add added-directory &&
168 cd .. &&
169 (cd svnwc; svn info added-directory) \
170 > expected.info-added-directory &&
171 (cd gitwc; git svn info added-directory) \
172 > actual.info-added-directory &&
173 test_cmp expected.info-added-directory actual.info-added-directory
176 test_expect_success 'info --url added-directory' '
177 test "$(cd gitwc; git svn info --url added-directory)" \
178 = "$quoted_svnrepo/added-directory"
181 test_expect_success 'info added-symlink-file' "
182 cd gitwc &&
183 ln -s added-file added-symlink-file &&
184 git add added-symlink-file &&
185 cd .. &&
186 cd svnwc &&
187 ln -s added-file added-symlink-file &&
188 svn_cmd add added-symlink-file > /dev/null &&
189 cd .. &&
190 ptouch gitwc/added-symlink-file svnwc/added-symlink-file &&
191 (cd svnwc; svn info added-symlink-file) \
192 > expected.info-added-symlink-file &&
193 (cd gitwc; git svn info added-symlink-file) \
194 > actual.info-added-symlink-file &&
195 test_cmp expected.info-added-symlink-file \
196 actual.info-added-symlink-file
199 test_expect_success 'info --url added-symlink-file' '
200 test "$(cd gitwc; git svn info --url added-symlink-file)" \
201 = "$quoted_svnrepo/added-symlink-file"
204 test_expect_success 'info added-symlink-directory' "
205 cd gitwc &&
206 ln -s added-directory added-symlink-directory &&
207 git add added-symlink-directory &&
208 cd .. &&
209 cd svnwc &&
210 ln -s added-directory added-symlink-directory &&
211 svn_cmd add added-symlink-directory > /dev/null &&
212 cd .. &&
213 ptouch gitwc/added-symlink-directory svnwc/added-symlink-directory &&
214 (cd svnwc; svn info added-symlink-directory) \
215 > expected.info-added-symlink-directory &&
216 (cd gitwc; git svn info added-symlink-directory) \
217 > actual.info-added-symlink-directory &&
218 test_cmp expected.info-added-symlink-directory \
219 actual.info-added-symlink-directory
222 test_expect_success 'info --url added-symlink-directory' '
223 test "$(cd gitwc; git svn info --url added-symlink-directory)" \
224 = "$quoted_svnrepo/added-symlink-directory"
227 # The next few tests replace the "Text Last Updated" value with a
228 # placeholder since git doesn't have a way to know the date that a
229 # now-deleted file was last checked out locally. Internally it
230 # simply reuses the Last Changed Date.
232 test_expect_success 'info deleted-file' "
233 cd gitwc &&
234 git rm -f file > /dev/null &&
235 cd .. &&
236 cd svnwc &&
237 svn_cmd rm --force file > /dev/null &&
238 cd .. &&
239 (cd svnwc; svn info file) |
240 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
241 > expected.info-deleted-file &&
242 (cd gitwc; git svn info file) |
243 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
244 > actual.info-deleted-file &&
245 test_cmp expected.info-deleted-file actual.info-deleted-file
248 test_expect_success 'info --url file (deleted)' '
249 test "$(cd gitwc; git svn info --url file)" \
250 = "$quoted_svnrepo/file"
253 test_expect_success 'info deleted-directory' "
254 cd gitwc &&
255 git rm -r -f directory > /dev/null &&
256 cd .. &&
257 cd svnwc &&
258 svn_cmd rm --force directory > /dev/null &&
259 cd .. &&
260 (cd svnwc; svn info directory) |
261 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
262 > expected.info-deleted-directory &&
263 (cd gitwc; git svn info directory) |
264 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
265 > actual.info-deleted-directory &&
266 test_cmp expected.info-deleted-directory actual.info-deleted-directory
269 test_expect_success 'info --url directory (deleted)' '
270 test "$(cd gitwc; git svn info --url directory)" \
271 = "$quoted_svnrepo/directory"
274 test_expect_success 'info deleted-symlink-file' "
275 cd gitwc &&
276 git rm -f symlink-file > /dev/null &&
277 cd .. &&
278 cd svnwc &&
279 svn_cmd rm --force symlink-file > /dev/null &&
280 cd .. &&
281 (cd svnwc; svn info symlink-file) |
282 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
283 > expected.info-deleted-symlink-file &&
284 (cd gitwc; git svn info symlink-file) |
285 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
286 > actual.info-deleted-symlink-file &&
287 test_cmp expected.info-deleted-symlink-file \
288 actual.info-deleted-symlink-file
291 test_expect_success 'info --url symlink-file (deleted)' '
292 test "$(cd gitwc; git svn info --url symlink-file)" \
293 = "$quoted_svnrepo/symlink-file"
296 test_expect_success 'info deleted-symlink-directory' "
297 cd gitwc &&
298 git rm -f symlink-directory > /dev/null &&
299 cd .. &&
300 cd svnwc &&
301 svn_cmd rm --force symlink-directory > /dev/null &&
302 cd .. &&
303 (cd svnwc; svn info symlink-directory) |
304 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
305 > expected.info-deleted-symlink-directory &&
306 (cd gitwc; git svn info symlink-directory) |
307 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
308 > actual.info-deleted-symlink-directory &&
309 test_cmp expected.info-deleted-symlink-directory \
310 actual.info-deleted-symlink-directory
313 test_expect_success 'info --url symlink-directory (deleted)' '
314 test "$(cd gitwc; git svn info --url symlink-directory)" \
315 = "$quoted_svnrepo/symlink-directory"
318 # NOTE: git does not have the concept of replaced objects,
319 # so we can't test for files in that state.
321 test_expect_success 'info unknown-file' "
322 echo two > gitwc/unknown-file &&
323 (cd gitwc; test_must_fail git svn info unknown-file) \
324 2> actual.info-unknown-file &&
325 grep unknown-file actual.info-unknown-file
328 test_expect_success 'info --url unknown-file' '
329 echo two > gitwc/unknown-file &&
330 (cd gitwc; test_must_fail git svn info --url unknown-file) \
331 2> actual.info-url-unknown-file &&
332 grep unknown-file actual.info-url-unknown-file
335 test_expect_success 'info unknown-directory' "
336 mkdir gitwc/unknown-directory svnwc/unknown-directory &&
337 (cd gitwc; test_must_fail git svn info unknown-directory) \
338 2> actual.info-unknown-directory &&
339 grep unknown-directory actual.info-unknown-directory
342 test_expect_success 'info --url unknown-directory' '
343 (cd gitwc; test_must_fail git svn info --url unknown-directory) \
344 2> actual.info-url-unknown-directory &&
345 grep unknown-directory actual.info-url-unknown-directory
348 test_expect_success 'info unknown-symlink-file' "
349 cd gitwc &&
350 ln -s unknown-file unknown-symlink-file &&
351 cd .. &&
352 (cd gitwc; test_must_fail git svn info unknown-symlink-file) \
353 2> actual.info-unknown-symlink-file &&
354 grep unknown-symlink-file actual.info-unknown-symlink-file
357 test_expect_success 'info --url unknown-symlink-file' '
358 (cd gitwc; test_must_fail git svn info --url unknown-symlink-file) \
359 2> actual.info-url-unknown-symlink-file &&
360 grep unknown-symlink-file actual.info-url-unknown-symlink-file
363 test_expect_success 'info unknown-symlink-directory' "
364 cd gitwc &&
365 ln -s unknown-directory unknown-symlink-directory &&
366 cd .. &&
367 (cd gitwc; test_must_fail git svn info unknown-symlink-directory) \
368 2> actual.info-unknown-symlink-directory &&
369 grep unknown-symlink-directory actual.info-unknown-symlink-directory
372 test_expect_success 'info --url unknown-symlink-directory' '
373 (cd gitwc; test_must_fail git svn info --url unknown-symlink-directory) \
374 2> actual.info-url-unknown-symlink-directory &&
375 grep unknown-symlink-directory actual.info-url-unknown-symlink-directory
378 test_done