git-cvsserver runs hooks/post-receive
[git/jnareb-git.git] / t / t9119-git-svn-info.sh
blob439bd93c886091f820a7de48a0fe92966e31fe1c
1 #!/bin/sh
3 # Copyright (c) 2007 David D. Kilzer
5 test_description='git-svn info'
7 . ./lib-git-svn.sh
9 ptouch() {
10 perl -w -e '
11 use strict;
12 die "ptouch requires exactly 2 arguments" if @ARGV != 2;
13 die "$ARGV[0] does not exist" if ! -e $ARGV[0];
14 my @s = stat $ARGV[0];
15 utime $s[8], $s[9], $ARGV[1];
16 ' "$1" "$2"
19 test_expect_success 'setup repository and import' "
20 mkdir info &&
21 cd info &&
22 echo FIRST > A &&
23 echo one > file &&
24 ln -s file symlink-file &&
25 mkdir directory &&
26 touch directory/.placeholder &&
27 ln -s directory symlink-directory &&
28 svn import -m 'initial' . $svnrepo &&
29 cd .. &&
30 mkdir gitwc &&
31 cd gitwc &&
32 git-svn init $svnrepo &&
33 git-svn fetch &&
34 cd .. &&
35 svn co $svnrepo svnwc &&
36 ptouch svnwc/file gitwc/file &&
37 ptouch svnwc/directory gitwc/directory &&
38 ptouch svnwc/symlink-file gitwc/symlink-file &&
39 ptouch svnwc/symlink-directory gitwc/symlink-directory
42 test_expect_success 'info' "
43 (cd svnwc; svn info) > expected.info &&
44 (cd gitwc; git-svn info) > actual.info &&
45 git-diff expected.info actual.info
48 test_expect_success 'info --url' '
49 test $(cd gitwc; git-svn info --url) = $svnrepo
52 test_expect_success 'info .' "
53 (cd svnwc; svn info .) > expected.info-dot &&
54 (cd gitwc; git-svn info .) > actual.info-dot &&
55 git-diff expected.info-dot actual.info-dot
58 test_expect_success 'info --url .' '
59 test $(cd gitwc; git-svn info --url .) = $svnrepo
62 test_expect_success 'info file' "
63 (cd svnwc; svn info file) > expected.info-file &&
64 (cd gitwc; git-svn info file) > actual.info-file &&
65 git-diff expected.info-file actual.info-file
68 test_expect_success 'info --url file' '
69 test $(cd gitwc; git-svn info --url file) = "$svnrepo/file"
72 test_expect_success 'info directory' "
73 (cd svnwc; svn info directory) > expected.info-directory &&
74 (cd gitwc; git-svn info directory) > actual.info-directory &&
75 git-diff expected.info-directory actual.info-directory
78 test_expect_success 'info --url directory' '
79 test $(cd gitwc; git-svn info --url directory) = "$svnrepo/directory"
82 test_expect_success 'info symlink-file' "
83 (cd svnwc; svn info symlink-file) > expected.info-symlink-file &&
84 (cd gitwc; git-svn info symlink-file) > actual.info-symlink-file &&
85 git-diff expected.info-symlink-file actual.info-symlink-file
88 test_expect_success 'info --url symlink-file' '
89 test $(cd gitwc; git-svn info --url symlink-file) \
90 = "$svnrepo/symlink-file"
93 test_expect_success 'info symlink-directory' "
94 (cd svnwc; svn info symlink-directory) \
95 > expected.info-symlink-directory &&
96 (cd gitwc; git-svn info symlink-directory) \
97 > actual.info-symlink-directory &&
98 git-diff expected.info-symlink-directory actual.info-symlink-directory
101 test_expect_success 'info --url symlink-directory' '
102 test $(cd gitwc; git-svn info --url symlink-directory) \
103 = "$svnrepo/symlink-directory"
106 test_expect_success 'info added-file' "
107 echo two > gitwc/added-file &&
108 cd gitwc &&
109 git add added-file &&
110 cd .. &&
111 cp gitwc/added-file svnwc/added-file &&
112 ptouch gitwc/added-file svnwc/added-file &&
113 cd svnwc &&
114 svn add added-file > /dev/null &&
115 cd .. &&
116 (cd svnwc; svn info added-file) > expected.info-added-file &&
117 (cd gitwc; git-svn info added-file) > actual.info-added-file &&
118 git-diff expected.info-added-file actual.info-added-file
121 test_expect_success 'info --url added-file' '
122 test $(cd gitwc; git-svn info --url added-file) \
123 = "$svnrepo/added-file"
126 test_expect_success 'info added-directory' "
127 mkdir gitwc/added-directory svnwc/added-directory &&
128 ptouch gitwc/added-directory svnwc/added-directory &&
129 touch gitwc/added-directory/.placeholder &&
130 cd svnwc &&
131 svn add added-directory > /dev/null &&
132 cd .. &&
133 cd gitwc &&
134 git add added-directory &&
135 cd .. &&
136 (cd svnwc; svn info added-directory) \
137 > expected.info-added-directory &&
138 (cd gitwc; git-svn info added-directory) \
139 > actual.info-added-directory &&
140 git-diff expected.info-added-directory actual.info-added-directory
143 test_expect_success 'info --url added-directory' '
144 test $(cd gitwc; git-svn info --url added-directory) \
145 = "$svnrepo/added-directory"
148 test_expect_success 'info added-symlink-file' "
149 cd gitwc &&
150 ln -s added-file added-symlink-file &&
151 git add added-symlink-file &&
152 cd .. &&
153 cd svnwc &&
154 ln -s added-file added-symlink-file &&
155 svn add added-symlink-file > /dev/null &&
156 cd .. &&
157 ptouch gitwc/added-symlink-file svnwc/added-symlink-file &&
158 (cd svnwc; svn info added-symlink-file) \
159 > expected.info-added-symlink-file &&
160 (cd gitwc; git-svn info added-symlink-file) \
161 > actual.info-added-symlink-file &&
162 git-diff expected.info-added-symlink-file \
163 actual.info-added-symlink-file
166 test_expect_success 'info --url added-symlink-file' '
167 test $(cd gitwc; git-svn info --url added-symlink-file) \
168 = "$svnrepo/added-symlink-file"
171 test_expect_success 'info added-symlink-directory' "
172 cd gitwc &&
173 ln -s added-directory added-symlink-directory &&
174 git add added-symlink-directory &&
175 cd .. &&
176 cd svnwc &&
177 ln -s added-directory added-symlink-directory &&
178 svn add added-symlink-directory > /dev/null &&
179 cd .. &&
180 ptouch gitwc/added-symlink-directory svnwc/added-symlink-directory &&
181 (cd svnwc; svn info added-symlink-directory) \
182 > expected.info-added-symlink-directory &&
183 (cd gitwc; git-svn info added-symlink-directory) \
184 > actual.info-added-symlink-directory &&
185 git-diff expected.info-added-symlink-directory \
186 actual.info-added-symlink-directory
189 test_expect_success 'info --url added-symlink-directory' '
190 test $(cd gitwc; git-svn info --url added-symlink-directory) \
191 = "$svnrepo/added-symlink-directory"
194 # The next few tests replace the "Text Last Updated" value with a
195 # placeholder since git doesn't have a way to know the date that a
196 # now-deleted file was last checked out locally. Internally it
197 # simply reuses the Last Changed Date.
199 test_expect_success 'info deleted-file' "
200 cd gitwc &&
201 git rm -f file > /dev/null &&
202 cd .. &&
203 cd svnwc &&
204 svn rm --force file > /dev/null &&
205 cd .. &&
206 (cd svnwc; svn info file) |
207 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
208 > expected.info-deleted-file &&
209 (cd gitwc; git-svn info file) |
210 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
211 > actual.info-deleted-file &&
212 git-diff expected.info-deleted-file actual.info-deleted-file
215 test_expect_success 'info --url file (deleted)' '
216 test $(cd gitwc; git-svn info --url file) \
217 = "$svnrepo/file"
220 test_expect_success 'info deleted-directory' "
221 cd gitwc &&
222 git rm -r -f directory > /dev/null &&
223 cd .. &&
224 cd svnwc &&
225 svn rm --force directory > /dev/null &&
226 cd .. &&
227 (cd svnwc; svn info directory) |
228 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
229 > expected.info-deleted-directory &&
230 (cd gitwc; git-svn info directory) |
231 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
232 > actual.info-deleted-directory &&
233 git-diff expected.info-deleted-directory actual.info-deleted-directory
236 test_expect_success 'info --url directory (deleted)' '
237 test $(cd gitwc; git-svn info --url directory) \
238 = "$svnrepo/directory"
241 test_expect_success 'info deleted-symlink-file' "
242 cd gitwc &&
243 git rm -f symlink-file > /dev/null &&
244 cd .. &&
245 cd svnwc &&
246 svn rm --force symlink-file > /dev/null &&
247 cd .. &&
248 (cd svnwc; svn info symlink-file) |
249 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
250 > expected.info-deleted-symlink-file &&
251 (cd gitwc; git-svn info symlink-file) |
252 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
253 > actual.info-deleted-symlink-file &&
254 git-diff expected.info-deleted-symlink-file \
255 actual.info-deleted-symlink-file
258 test_expect_success 'info --url symlink-file (deleted)' '
259 test $(cd gitwc; git-svn info --url symlink-file) \
260 = "$svnrepo/symlink-file"
263 test_expect_success 'info deleted-symlink-directory' "
264 cd gitwc &&
265 git rm -f symlink-directory > /dev/null &&
266 cd .. &&
267 cd svnwc &&
268 svn rm --force symlink-directory > /dev/null &&
269 cd .. &&
270 (cd svnwc; svn info symlink-directory) |
271 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
272 > expected.info-deleted-symlink-directory &&
273 (cd gitwc; git-svn info symlink-directory) |
274 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
275 > actual.info-deleted-symlink-directory &&
276 git-diff expected.info-deleted-symlink-directory \
277 actual.info-deleted-symlink-directory
280 test_expect_success 'info --url symlink-directory (deleted)' '
281 test $(cd gitwc; git-svn info --url symlink-directory) \
282 = "$svnrepo/symlink-directory"
285 # NOTE: git does not have the concept of replaced objects,
286 # so we can't test for files in that state.
288 test_expect_success 'info unknown-file' "
289 echo two > gitwc/unknown-file &&
290 cp gitwc/unknown-file svnwc/unknown-file &&
291 ptouch gitwc/unknown-file svnwc/unknown-file &&
292 (cd svnwc; svn info unknown-file) 2> expected.info-unknown-file &&
293 (cd gitwc; git-svn info unknown-file) 2> actual.info-unknown-file &&
294 git-diff expected.info-unknown-file actual.info-unknown-file
297 test_expect_success 'info --url unknown-file' '
298 test -z $(cd gitwc; git-svn info --url unknown-file \
299 2> ../actual.info--url-unknown-file) &&
300 git-diff expected.info-unknown-file actual.info--url-unknown-file
303 test_expect_success 'info unknown-directory' "
304 mkdir gitwc/unknown-directory svnwc/unknown-directory &&
305 ptouch gitwc/unknown-directory svnwc/unknown-directory &&
306 touch gitwc/unknown-directory/.placeholder &&
307 (cd svnwc; svn info unknown-directory) \
308 2> expected.info-unknown-directory &&
309 (cd gitwc; git-svn info unknown-directory) \
310 2> actual.info-unknown-directory &&
311 git-diff expected.info-unknown-directory actual.info-unknown-directory
314 test_expect_success 'info --url unknown-directory' '
315 test -z $(cd gitwc; git-svn info --url unknown-directory \
316 2> ../actual.info--url-unknown-directory) &&
317 git-diff expected.info-unknown-directory \
318 actual.info--url-unknown-directory
321 test_expect_success 'info unknown-symlink-file' "
322 cd gitwc &&
323 ln -s unknown-file unknown-symlink-file &&
324 cd .. &&
325 cd svnwc &&
326 ln -s unknown-file unknown-symlink-file &&
327 cd .. &&
328 ptouch gitwc/unknown-symlink-file svnwc/unknown-symlink-file &&
329 (cd svnwc; svn info unknown-symlink-file) \
330 2> expected.info-unknown-symlink-file &&
331 (cd gitwc; git-svn info unknown-symlink-file) \
332 2> actual.info-unknown-symlink-file &&
333 git-diff expected.info-unknown-symlink-file \
334 actual.info-unknown-symlink-file
337 test_expect_success 'info --url unknown-symlink-file' '
338 test -z $(cd gitwc; git-svn info --url unknown-symlink-file \
339 2> ../actual.info--url-unknown-symlink-file) &&
340 git-diff expected.info-unknown-symlink-file \
341 actual.info--url-unknown-symlink-file
344 test_expect_success 'info unknown-symlink-directory' "
345 cd gitwc &&
346 ln -s unknown-directory unknown-symlink-directory &&
347 cd .. &&
348 cd svnwc &&
349 ln -s unknown-directory unknown-symlink-directory &&
350 cd .. &&
351 ptouch gitwc/unknown-symlink-directory \
352 svnwc/unknown-symlink-directory &&
353 (cd svnwc; svn info unknown-symlink-directory) \
354 2> expected.info-unknown-symlink-directory &&
355 (cd gitwc; git-svn info unknown-symlink-directory) \
356 2> actual.info-unknown-symlink-directory &&
357 git-diff expected.info-unknown-symlink-directory \
358 actual.info-unknown-symlink-directory
361 test_expect_success 'info --url unknown-symlink-directory' '
362 test -z $(cd gitwc; git-svn info --url unknown-symlink-directory \
363 2> ../actual.info--url-unknown-symlink-directory) &&
364 git-diff expected.info-unknown-symlink-directory \
365 actual.info--url-unknown-symlink-directory
368 test_done