3 # Copyright (c) 2007 David D. Kilzer
5 test_description='git svn info'
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'`
16 say "skipping svn-info test (SVN version: $v not supported)"
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);
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' '
45 ln -s file symlink-file &&
47 touch directory/.placeholder &&
48 ln -s directory symlink-directory &&
49 svn_cmd import -m "initial" . "$svnrepo" &&
51 svn_cmd co "$svnrepo" svnwc &&
55 svn_cmd commit -m "change outside directory" &&
60 git svn init "$svnrepo" &&
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 &&
142 git add added-file &&
144 cp gitwc/added-file svnwc/added-file &&
145 ptouch gitwc/added-file svnwc/added-file &&
147 svn_cmd add added-file > /dev/null &&
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 &&
164 svn_cmd add added-directory > /dev/null &&
167 git add added-directory &&
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' "
183 ln -s added-file added-symlink-file &&
184 git add added-symlink-file &&
187 ln -s added-file added-symlink-file &&
188 svn_cmd add added-symlink-file > /dev/null &&
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' "
206 ln -s added-directory added-symlink-directory &&
207 git add added-symlink-directory &&
210 ln -s added-directory added-symlink-directory &&
211 svn_cmd add added-symlink-directory > /dev/null &&
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' "
234 git rm -f file > /dev/null &&
237 svn_cmd rm --force file > /dev/null &&
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' "
255 git rm -r -f directory > /dev/null &&
258 svn_cmd rm --force directory > /dev/null &&
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' "
276 git rm -f symlink-file > /dev/null &&
279 svn_cmd rm --force symlink-file > /dev/null &&
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' "
298 git rm -f symlink-directory > /dev/null &&
301 svn_cmd rm --force symlink-directory > /dev/null &&
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' "
350 ln -s unknown-file unknown-symlink-file &&
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' "
365 ln -s unknown-directory unknown-symlink-directory &&
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