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 skip_all
="skipping svn-info test (SVN version: $v not supported)"
21 # On the "Text Last Updated" line, "git svn info" does not return the
22 # same value as "svn info" (i.e. the commit timestamp that touched the
23 # path most recently); do not expect that field to match.
25 sed -e '/^Text Last Updated:/d' "$1" >tmp.expect
&&
26 sed -e '/^Text Last Updated:/d' "$2" >tmp.actual
&&
27 test_cmp tmp.expect tmp.actual
&&
28 rm -f tmp.expect tmp.actual
31 quoted_svnrepo
="$(echo $svnrepo | test_uri_escape)"
33 test_expect_success
'setup repository and import' '
39 ln -s file symlink-file &&
41 touch directory/.placeholder &&
42 ln -s directory symlink-directory &&
43 svn_cmd import -m "initial" . "$svnrepo"
45 svn_cmd co "$svnrepo" svnwc &&
50 svn_cmd commit -m "change outside directory" &&
56 git svn init "$svnrepo" &&
61 test_expect_success
'info' "
62 (cd svnwc && svn info) > expected.info &&
63 (cd gitwc && git svn info) > actual.info &&
64 test_cmp_info expected.info actual.info
67 test_expect_success
'info --url' '
68 test "$(cd gitwc && git svn info --url)" = "$quoted_svnrepo"
71 test_expect_success
'info .' "
72 (cd svnwc && svn info .) > expected.info-dot &&
73 (cd gitwc && git svn info .) > actual.info-dot &&
74 test_cmp_info expected.info-dot actual.info-dot
77 test_expect_success
'info $(pwd)' '
78 (cd svnwc && svn info "$(pwd)") >expected.info-pwd &&
79 (cd gitwc && git svn info "$(pwd)") >actual.info-pwd &&
80 grep -v ^Path: <expected.info-pwd >expected.info-np &&
81 grep -v ^Path: <actual.info-pwd >actual.info-np &&
82 test_cmp_info expected.info-np actual.info-np &&
83 test "$(sed -ne \"/^Path:/ s!/svnwc!!\" <expected.info-pwd)" = \
84 "$(sed -ne \"/^Path:/ s!/gitwc!!\" <actual.info-pwd)"
87 test_expect_success
'info $(pwd)/../___wc' '
88 (cd svnwc && svn info "$(pwd)/../svnwc") >expected.info-pwd &&
89 (cd gitwc && git svn info "$(pwd)/../gitwc") >actual.info-pwd &&
90 grep -v ^Path: <expected.info-pwd >expected.info-np &&
91 grep -v ^Path: <actual.info-pwd >actual.info-np &&
92 test_cmp_info expected.info-np actual.info-np &&
93 test "$(sed -ne \"/^Path:/ s!/svnwc!!\" <expected.info-pwd)" = \
94 "$(sed -ne \"/^Path:/ s!/gitwc!!\" <actual.info-pwd)"
97 test_expect_success
'info $(pwd)/../___wc//file' '
98 (cd svnwc && svn info "$(pwd)/../svnwc//file") >expected.info-pwd &&
99 (cd gitwc && git svn info "$(pwd)/../gitwc//file") >actual.info-pwd &&
100 grep -v ^Path: <expected.info-pwd >expected.info-np &&
101 grep -v ^Path: <actual.info-pwd >actual.info-np &&
102 test_cmp_info expected.info-np actual.info-np &&
103 test "$(sed -ne \"/^Path:/ s!/svnwc!!\" <expected.info-pwd)" = \
104 "$(sed -ne \"/^Path:/ s!/gitwc!!\" <actual.info-pwd)"
107 test_expect_success
'info --url .' '
108 test "$(cd gitwc && git svn info --url .)" = "$quoted_svnrepo"
111 test_expect_success
'info file' "
112 (cd svnwc && svn info file) > expected.info-file &&
113 (cd gitwc && git svn info file) > actual.info-file &&
114 test_cmp_info expected.info-file actual.info-file
117 test_expect_success
'info --url file' '
118 test "$(cd gitwc && git svn info --url file)" = "$quoted_svnrepo/file"
121 test_expect_success
'info directory' "
122 (cd svnwc && svn info directory) > expected.info-directory &&
123 (cd gitwc && git svn info directory) > actual.info-directory &&
124 test_cmp_info expected.info-directory actual.info-directory
127 test_expect_success
'info inside directory' "
128 (cd svnwc/directory && svn info) > expected.info-inside-directory &&
129 (cd gitwc/directory && git svn info) > actual.info-inside-directory &&
130 test_cmp_info expected.info-inside-directory actual.info-inside-directory
133 test_expect_success
'info --url directory' '
134 test "$(cd gitwc && git svn info --url directory)" = "$quoted_svnrepo/directory"
137 test_expect_success
'info symlink-file' "
138 (cd svnwc && svn info symlink-file) > expected.info-symlink-file &&
139 (cd gitwc && git svn info symlink-file) > actual.info-symlink-file &&
140 test_cmp_info expected.info-symlink-file actual.info-symlink-file
143 test_expect_success
'info --url symlink-file' '
144 test "$(cd gitwc && git svn info --url symlink-file)" \
145 = "$quoted_svnrepo/symlink-file"
148 test_expect_success
'info symlink-directory' "
149 (cd svnwc && svn info symlink-directory) \
150 > expected.info-symlink-directory &&
151 (cd gitwc && git svn info symlink-directory) \
152 > actual.info-symlink-directory &&
153 test_cmp_info expected.info-symlink-directory actual.info-symlink-directory
156 test_expect_success
'info --url symlink-directory' '
157 test "$(cd gitwc && git svn info --url symlink-directory)" \
158 = "$quoted_svnrepo/symlink-directory"
161 test_expect_success
'info added-file' "
162 echo two > gitwc/added-file &&
167 cp gitwc/added-file svnwc/added-file &&
170 svn_cmd add added-file > /dev/null
172 (cd svnwc && svn info added-file) > expected.info-added-file &&
173 (cd gitwc && git svn info added-file) > actual.info-added-file &&
174 test_cmp_info expected.info-added-file actual.info-added-file
177 test_expect_success
'info --url added-file' '
178 test "$(cd gitwc && git svn info --url added-file)" \
179 = "$quoted_svnrepo/added-file"
182 test_expect_success
'info added-directory' "
183 mkdir gitwc/added-directory svnwc/added-directory &&
184 touch gitwc/added-directory/.placeholder &&
187 svn_cmd add added-directory > /dev/null
191 git add added-directory
193 (cd svnwc && svn info added-directory) \
194 > expected.info-added-directory &&
195 (cd gitwc && git svn info added-directory) \
196 > actual.info-added-directory &&
197 test_cmp_info expected.info-added-directory actual.info-added-directory
200 test_expect_success
'info --url added-directory' '
201 test "$(cd gitwc && git svn info --url added-directory)" \
202 = "$quoted_svnrepo/added-directory"
205 test_expect_success
'info added-symlink-file' "
208 ln -s added-file added-symlink-file &&
209 git add added-symlink-file
213 ln -s added-file added-symlink-file &&
214 svn_cmd add added-symlink-file > /dev/null
216 (cd svnwc && svn info added-symlink-file) \
217 > expected.info-added-symlink-file &&
218 (cd gitwc && git svn info added-symlink-file) \
219 > actual.info-added-symlink-file &&
220 test_cmp_info expected.info-added-symlink-file \
221 actual.info-added-symlink-file
224 test_expect_success
'info --url added-symlink-file' '
225 test "$(cd gitwc && git svn info --url added-symlink-file)" \
226 = "$quoted_svnrepo/added-symlink-file"
229 test_expect_success
'info added-symlink-directory' "
232 ln -s added-directory added-symlink-directory &&
233 git add added-symlink-directory
237 ln -s added-directory added-symlink-directory &&
238 svn_cmd add added-symlink-directory > /dev/null
240 (cd svnwc && svn info added-symlink-directory) \
241 > expected.info-added-symlink-directory &&
242 (cd gitwc && git svn info added-symlink-directory) \
243 > actual.info-added-symlink-directory &&
244 test_cmp_info expected.info-added-symlink-directory \
245 actual.info-added-symlink-directory
248 test_expect_success
'info --url added-symlink-directory' '
249 test "$(cd gitwc && git svn info --url added-symlink-directory)" \
250 = "$quoted_svnrepo/added-symlink-directory"
253 test_expect_success
'info deleted-file' "
256 git rm -f file > /dev/null
260 svn_cmd rm --force file > /dev/null
262 (cd svnwc && svn info file) >expected.info-deleted-file &&
263 (cd gitwc && git svn info file) >actual.info-deleted-file &&
264 test_cmp_info expected.info-deleted-file actual.info-deleted-file
267 test_expect_success
'info --url file (deleted)' '
268 test "$(cd gitwc && git svn info --url file)" \
269 = "$quoted_svnrepo/file"
272 test_expect_success
'info deleted-directory' "
275 git rm -r -f directory > /dev/null
279 svn_cmd rm --force directory > /dev/null
281 (cd svnwc && svn info directory) >expected.info-deleted-directory &&
282 (cd gitwc && git svn info directory) >actual.info-deleted-directory &&
283 test_cmp_info expected.info-deleted-directory actual.info-deleted-directory
286 test_expect_success
'info --url directory (deleted)' '
287 test "$(cd gitwc && git svn info --url directory)" \
288 = "$quoted_svnrepo/directory"
291 test_expect_success
'info deleted-symlink-file' "
294 git rm -f symlink-file > /dev/null
298 svn_cmd rm --force symlink-file > /dev/null
300 (cd svnwc && svn info symlink-file) >expected.info-deleted-symlink-file &&
301 (cd gitwc && git svn info symlink-file) >actual.info-deleted-symlink-file &&
302 test_cmp_info expected.info-deleted-symlink-file actual.info-deleted-symlink-file
305 test_expect_success
'info --url symlink-file (deleted)' '
306 test "$(cd gitwc && git svn info --url symlink-file)" \
307 = "$quoted_svnrepo/symlink-file"
310 test_expect_success
'info deleted-symlink-directory' "
313 git rm -f symlink-directory > /dev/null
317 svn_cmd rm --force symlink-directory > /dev/null
319 (cd svnwc && svn info symlink-directory) >expected.info-deleted-symlink-directory &&
320 (cd gitwc && git svn info symlink-directory) >actual.info-deleted-symlink-directory &&
321 test_cmp_info expected.info-deleted-symlink-directory actual.info-deleted-symlink-directory
324 test_expect_success
'info --url symlink-directory (deleted)' '
325 test "$(cd gitwc && git svn info --url symlink-directory)" \
326 = "$quoted_svnrepo/symlink-directory"
329 # NOTE: git does not have the concept of replaced objects,
330 # so we can't test for files in that state.
332 test_expect_success
'info unknown-file' "
333 echo two > gitwc/unknown-file &&
334 (cd gitwc && test_must_fail git svn info unknown-file) \
335 2> actual.info-unknown-file &&
336 grep unknown-file actual.info-unknown-file
339 test_expect_success
'info --url unknown-file' '
340 echo two > gitwc/unknown-file &&
341 (cd gitwc && test_must_fail git svn info --url unknown-file) \
342 2> actual.info-url-unknown-file &&
343 grep unknown-file actual.info-url-unknown-file
346 test_expect_success
'info unknown-directory' "
347 mkdir gitwc/unknown-directory svnwc/unknown-directory &&
348 (cd gitwc && test_must_fail git svn info unknown-directory) \
349 2> actual.info-unknown-directory &&
350 grep unknown-directory actual.info-unknown-directory
353 test_expect_success
'info --url unknown-directory' '
354 (cd gitwc && test_must_fail git svn info --url unknown-directory) \
355 2> actual.info-url-unknown-directory &&
356 grep unknown-directory actual.info-url-unknown-directory
359 test_expect_success
'info unknown-symlink-file' "
362 ln -s unknown-file unknown-symlink-file
364 (cd gitwc && test_must_fail git svn info unknown-symlink-file) \
365 2> actual.info-unknown-symlink-file &&
366 grep unknown-symlink-file actual.info-unknown-symlink-file
369 test_expect_success
'info --url unknown-symlink-file' '
370 (cd gitwc && test_must_fail git svn info --url unknown-symlink-file) \
371 2> actual.info-url-unknown-symlink-file &&
372 grep unknown-symlink-file actual.info-url-unknown-symlink-file
375 test_expect_success
'info unknown-symlink-directory' "
378 ln -s unknown-directory unknown-symlink-directory
380 (cd gitwc && test_must_fail git svn info unknown-symlink-directory) \
381 2> actual.info-unknown-symlink-directory &&
382 grep unknown-symlink-directory actual.info-unknown-symlink-directory
385 test_expect_success
'info --url unknown-symlink-directory' '
386 (cd gitwc && test_must_fail git svn info --url unknown-symlink-directory) \
387 2> actual.info-url-unknown-symlink-directory &&
388 grep unknown-symlink-directory actual.info-url-unknown-symlink-directory