3 # Copyright (c) 2007 David D. Kilzer
5 test_description='git-svn info'
11 # Tested with: svn, version 1.4.4 (r25188)
12 v=`svn --version | sed -n -e 's/^svn, version \(1\.4\.[0-9]\).*$/\1/p'`
17 say "skipping svn-info test (SVN version: $v not supported)"
26 die "ptouch requires exactly 2 arguments" if @ARGV != 2;
27 my $text_last_updated = shift @ARGV;
28 my $git_file = shift @ARGV;
29 die "\"$git_file\" does not exist" if ! -e $git_file;
30 if ($text_last_updated
31 =~ /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/) {
32 my $mtime = mktime($6, $5, $4, $3, $2 - 1, $1 - 1900);
34 utime $atime, $mtime, $git_file;
36 ' "`svn info $2 | grep '^Text Last Updated:'`" "$1"
39 test_expect_success 'setup repository and import' '
44 ln -s file symlink-file &&
46 touch directory/.placeholder &&
47 ln -s directory symlink-directory &&
48 svn import -m "initial" . "$svnrepo" &&
52 git-svn init "$svnrepo" &&
55 svn co "$svnrepo" svnwc &&
56 ptouch svnwc/file gitwc/file &&
57 ptouch svnwc/directory gitwc/directory &&
58 ptouch svnwc/symlink-file gitwc/symlink-file &&
59 ptouch svnwc/symlink-directory gitwc/symlink-directory
62 test_expect_success 'info' "
63 (cd svnwc; svn info) > expected.info &&
64 (cd gitwc; git-svn info) > actual.info &&
65 git-diff expected.info actual.info
68 test_expect_success 'info --url' '
69 test "$(cd gitwc; git-svn info --url)" = "$svnrepo"
72 test_expect_success 'info .' "
73 (cd svnwc; svn info .) > expected.info-dot &&
74 (cd gitwc; git-svn info .) > actual.info-dot &&
75 git-diff expected.info-dot actual.info-dot
78 test_expect_success 'info --url .' '
79 test "$(cd gitwc; git-svn info --url .)" = "$svnrepo"
82 test_expect_success 'info file' "
83 (cd svnwc; svn info file) > expected.info-file &&
84 (cd gitwc; git-svn info file) > actual.info-file &&
85 git-diff expected.info-file actual.info-file
88 test_expect_success 'info --url file' '
89 test "$(cd gitwc; git-svn info --url file)" = "$svnrepo/file"
92 test_expect_success 'info directory' "
93 (cd svnwc; svn info directory) > expected.info-directory &&
94 (cd gitwc; git-svn info directory) > actual.info-directory &&
95 git-diff expected.info-directory actual.info-directory
98 test_expect_success 'info --url directory' '
99 test "$(cd gitwc; git-svn info --url directory)" = "$svnrepo/directory"
102 test_expect_success 'info symlink-file' "
103 (cd svnwc; svn info symlink-file) > expected.info-symlink-file &&
104 (cd gitwc; git-svn info symlink-file) > actual.info-symlink-file &&
105 git-diff expected.info-symlink-file actual.info-symlink-file
108 test_expect_success 'info --url symlink-file' '
109 test "$(cd gitwc; git-svn info --url symlink-file)" \
110 = "$svnrepo/symlink-file"
113 test_expect_success 'info symlink-directory' "
114 (cd svnwc; svn info symlink-directory) \
115 > expected.info-symlink-directory &&
116 (cd gitwc; git-svn info symlink-directory) \
117 > actual.info-symlink-directory &&
118 git-diff expected.info-symlink-directory actual.info-symlink-directory
121 test_expect_success 'info --url symlink-directory' '
122 test "$(cd gitwc; git-svn info --url symlink-directory)" \
123 = "$svnrepo/symlink-directory"
126 test_expect_success 'info added-file' "
127 echo two > gitwc/added-file &&
129 git add added-file &&
131 cp gitwc/added-file svnwc/added-file &&
132 ptouch gitwc/added-file svnwc/added-file &&
134 svn add added-file > /dev/null &&
136 (cd svnwc; svn info added-file) > expected.info-added-file &&
137 (cd gitwc; git-svn info added-file) > actual.info-added-file &&
138 git-diff expected.info-added-file actual.info-added-file
141 test_expect_success 'info --url added-file' '
142 test "$(cd gitwc; git-svn info --url added-file)" \
143 = "$svnrepo/added-file"
146 test_expect_success 'info added-directory' "
147 mkdir gitwc/added-directory svnwc/added-directory &&
148 ptouch gitwc/added-directory svnwc/added-directory &&
149 touch gitwc/added-directory/.placeholder &&
151 svn add added-directory > /dev/null &&
154 git add added-directory &&
156 (cd svnwc; svn info added-directory) \
157 > expected.info-added-directory &&
158 (cd gitwc; git-svn info added-directory) \
159 > actual.info-added-directory &&
160 git-diff expected.info-added-directory actual.info-added-directory
163 test_expect_success 'info --url added-directory' '
164 test "$(cd gitwc; git-svn info --url added-directory)" \
165 = "$svnrepo/added-directory"
168 test_expect_success 'info added-symlink-file' "
170 ln -s added-file added-symlink-file &&
171 git add added-symlink-file &&
174 ln -s added-file added-symlink-file &&
175 svn add added-symlink-file > /dev/null &&
177 ptouch gitwc/added-symlink-file svnwc/added-symlink-file &&
178 (cd svnwc; svn info added-symlink-file) \
179 > expected.info-added-symlink-file &&
180 (cd gitwc; git-svn info added-symlink-file) \
181 > actual.info-added-symlink-file &&
182 git-diff expected.info-added-symlink-file \
183 actual.info-added-symlink-file
186 test_expect_success 'info --url added-symlink-file' '
187 test "$(cd gitwc; git-svn info --url added-symlink-file)" \
188 = "$svnrepo/added-symlink-file"
191 test_expect_success 'info added-symlink-directory' "
193 ln -s added-directory added-symlink-directory &&
194 git add added-symlink-directory &&
197 ln -s added-directory added-symlink-directory &&
198 svn add added-symlink-directory > /dev/null &&
200 ptouch gitwc/added-symlink-directory svnwc/added-symlink-directory &&
201 (cd svnwc; svn info added-symlink-directory) \
202 > expected.info-added-symlink-directory &&
203 (cd gitwc; git-svn info added-symlink-directory) \
204 > actual.info-added-symlink-directory &&
205 git-diff expected.info-added-symlink-directory \
206 actual.info-added-symlink-directory
209 test_expect_success 'info --url added-symlink-directory' '
210 test "$(cd gitwc; git-svn info --url added-symlink-directory)" \
211 = "$svnrepo/added-symlink-directory"
214 # The next few tests replace the "Text Last Updated" value with a
215 # placeholder since git doesn't have a way to know the date that a
216 # now-deleted file was last checked out locally. Internally it
217 # simply reuses the Last Changed Date.
219 test_expect_success 'info deleted-file' "
221 git rm -f file > /dev/null &&
224 svn rm --force file > /dev/null &&
226 (cd svnwc; svn info file) |
227 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
228 > expected.info-deleted-file &&
229 (cd gitwc; git-svn info file) |
230 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
231 > actual.info-deleted-file &&
232 git-diff expected.info-deleted-file actual.info-deleted-file
235 test_expect_success 'info --url file (deleted)' '
236 test "$(cd gitwc; git-svn info --url file)" \
240 test_expect_success 'info deleted-directory' "
242 git rm -r -f directory > /dev/null &&
245 svn rm --force directory > /dev/null &&
247 (cd svnwc; svn info directory) |
248 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
249 > expected.info-deleted-directory &&
250 (cd gitwc; git-svn info directory) |
251 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
252 > actual.info-deleted-directory &&
253 git-diff expected.info-deleted-directory actual.info-deleted-directory
256 test_expect_success 'info --url directory (deleted)' '
257 test "$(cd gitwc; git-svn info --url directory)" \
258 = "$svnrepo/directory"
261 test_expect_success 'info deleted-symlink-file' "
263 git rm -f symlink-file > /dev/null &&
266 svn rm --force symlink-file > /dev/null &&
268 (cd svnwc; svn info symlink-file) |
269 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
270 > expected.info-deleted-symlink-file &&
271 (cd gitwc; git-svn info symlink-file) |
272 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
273 > actual.info-deleted-symlink-file &&
274 git-diff expected.info-deleted-symlink-file \
275 actual.info-deleted-symlink-file
278 test_expect_success 'info --url symlink-file (deleted)' '
279 test "$(cd gitwc; git-svn info --url symlink-file)" \
280 = "$svnrepo/symlink-file"
283 test_expect_success 'info deleted-symlink-directory' "
285 git rm -f symlink-directory > /dev/null &&
288 svn rm --force symlink-directory > /dev/null &&
290 (cd svnwc; svn info symlink-directory) |
291 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
292 > expected.info-deleted-symlink-directory &&
293 (cd gitwc; git-svn info symlink-directory) |
294 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
295 > actual.info-deleted-symlink-directory &&
296 git-diff expected.info-deleted-symlink-directory \
297 actual.info-deleted-symlink-directory
300 test_expect_success 'info --url symlink-directory (deleted)' '
301 test "$(cd gitwc; git-svn info --url symlink-directory)" \
302 = "$svnrepo/symlink-directory"
305 # NOTE: git does not have the concept of replaced objects,
306 # so we can't test for files in that state.
308 test_expect_success 'info unknown-file' "
309 echo two > gitwc/unknown-file &&
310 cp gitwc/unknown-file svnwc/unknown-file &&
311 ptouch gitwc/unknown-file svnwc/unknown-file &&
312 (cd svnwc; svn info unknown-file) 2> expected.info-unknown-file &&
313 (cd gitwc; git-svn info unknown-file) 2> actual.info-unknown-file &&
314 git-diff expected.info-unknown-file actual.info-unknown-file
317 test_expect_success 'info --url unknown-file' '
318 test -z "$(cd gitwc; git-svn info --url unknown-file \
319 2> ../actual.info--url-unknown-file)" &&
320 git-diff expected.info-unknown-file actual.info--url-unknown-file
323 test_expect_success 'info unknown-directory' "
324 mkdir gitwc/unknown-directory svnwc/unknown-directory &&
325 ptouch gitwc/unknown-directory svnwc/unknown-directory &&
326 touch gitwc/unknown-directory/.placeholder &&
327 (cd svnwc; svn info unknown-directory) \
328 2> expected.info-unknown-directory &&
329 (cd gitwc; git-svn info unknown-directory) \
330 2> actual.info-unknown-directory &&
331 git-diff expected.info-unknown-directory actual.info-unknown-directory
334 test_expect_success 'info --url unknown-directory' '
335 test -z "$(cd gitwc; git-svn info --url unknown-directory \
336 2> ../actual.info--url-unknown-directory)" &&
337 git-diff expected.info-unknown-directory \
338 actual.info--url-unknown-directory
341 test_expect_success 'info unknown-symlink-file' "
343 ln -s unknown-file unknown-symlink-file &&
346 ln -s unknown-file unknown-symlink-file &&
348 ptouch gitwc/unknown-symlink-file svnwc/unknown-symlink-file &&
349 (cd svnwc; svn info unknown-symlink-file) \
350 2> expected.info-unknown-symlink-file &&
351 (cd gitwc; git-svn info unknown-symlink-file) \
352 2> actual.info-unknown-symlink-file &&
353 git-diff expected.info-unknown-symlink-file \
354 actual.info-unknown-symlink-file
357 test_expect_success 'info --url unknown-symlink-file' '
358 test -z "$(cd gitwc; git-svn info --url unknown-symlink-file \
359 2> ../actual.info--url-unknown-symlink-file)" &&
360 git-diff expected.info-unknown-symlink-file \
361 actual.info--url-unknown-symlink-file
364 test_expect_success 'info unknown-symlink-directory' "
366 ln -s unknown-directory unknown-symlink-directory &&
369 ln -s unknown-directory unknown-symlink-directory &&
371 ptouch gitwc/unknown-symlink-directory \
372 svnwc/unknown-symlink-directory &&
373 (cd svnwc; svn info unknown-symlink-directory) \
374 2> expected.info-unknown-symlink-directory &&
375 (cd gitwc; git-svn info unknown-symlink-directory) \
376 2> actual.info-unknown-symlink-directory &&
377 git-diff expected.info-unknown-symlink-directory \
378 actual.info-unknown-symlink-directory
381 test_expect_success 'info --url unknown-symlink-directory' '
382 test -z "$(cd gitwc; git-svn info --url unknown-symlink-directory \
383 2> ../actual.info--url-unknown-symlink-directory)" &&
384 git-diff expected.info-unknown-symlink-directory \
385 actual.info--url-unknown-symlink-directory