diff: trivial style fix
[alt-git.git] / t / t9119-git-svn-info.sh
blobff19695e776f803aef03a18e70067c89aa3be218
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 # 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.
24 test_cmp_info () {
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 | sed 's/ /%20/')"
33 test_expect_success 'setup repository and import' '
34 mkdir info &&
36 cd info &&
37 echo FIRST >A &&
38 echo one >file &&
39 ln -s file symlink-file &&
40 mkdir directory &&
41 touch directory/.placeholder &&
42 ln -s directory symlink-directory &&
43 svn_cmd import -m "initial" . "$svnrepo"
44 ) &&
45 svn_cmd co "$svnrepo" svnwc &&
47 cd svnwc &&
48 echo foo >foo &&
49 svn_cmd add foo &&
50 svn_cmd commit -m "change outside directory" &&
51 svn_cmd update
52 ) &&
53 mkdir gitwc &&
55 cd gitwc &&
56 git svn init "$svnrepo" &&
57 git svn fetch
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 --url .' '
78 test "$(cd gitwc; git svn info --url .)" = "$quoted_svnrepo"
81 test_expect_success 'info file' "
82 (cd svnwc; svn info file) > expected.info-file &&
83 (cd gitwc; git svn info file) > actual.info-file &&
84 test_cmp_info expected.info-file actual.info-file
87 test_expect_success 'info --url file' '
88 test "$(cd gitwc; git svn info --url file)" = "$quoted_svnrepo/file"
91 test_expect_success 'info directory' "
92 (cd svnwc; svn info directory) > expected.info-directory &&
93 (cd gitwc; git svn info directory) > actual.info-directory &&
94 test_cmp_info expected.info-directory actual.info-directory
97 test_expect_success 'info inside directory' "
98 (cd svnwc/directory; svn info) > expected.info-inside-directory &&
99 (cd gitwc/directory; git svn info) > actual.info-inside-directory &&
100 test_cmp_info expected.info-inside-directory actual.info-inside-directory
103 test_expect_success 'info --url directory' '
104 test "$(cd gitwc; git svn info --url directory)" = "$quoted_svnrepo/directory"
107 test_expect_success 'info symlink-file' "
108 (cd svnwc; svn info symlink-file) > expected.info-symlink-file &&
109 (cd gitwc; git svn info symlink-file) > actual.info-symlink-file &&
110 test_cmp_info expected.info-symlink-file actual.info-symlink-file
113 test_expect_success 'info --url symlink-file' '
114 test "$(cd gitwc; git svn info --url symlink-file)" \
115 = "$quoted_svnrepo/symlink-file"
118 test_expect_success 'info symlink-directory' "
119 (cd svnwc; svn info symlink-directory) \
120 > expected.info-symlink-directory &&
121 (cd gitwc; git svn info symlink-directory) \
122 > actual.info-symlink-directory &&
123 test_cmp_info expected.info-symlink-directory actual.info-symlink-directory
126 test_expect_success 'info --url symlink-directory' '
127 test "$(cd gitwc; git svn info --url symlink-directory)" \
128 = "$quoted_svnrepo/symlink-directory"
131 test_expect_success 'info added-file' "
132 echo two > gitwc/added-file &&
134 cd gitwc &&
135 git add added-file
136 ) &&
137 cp gitwc/added-file svnwc/added-file &&
139 cd svnwc &&
140 svn_cmd add added-file > /dev/null
141 ) &&
142 (cd svnwc; svn info added-file) > expected.info-added-file &&
143 (cd gitwc; git svn info added-file) > actual.info-added-file &&
144 test_cmp_info expected.info-added-file actual.info-added-file
147 test_expect_success 'info --url added-file' '
148 test "$(cd gitwc; git svn info --url added-file)" \
149 = "$quoted_svnrepo/added-file"
152 test_expect_success 'info added-directory' "
153 mkdir gitwc/added-directory svnwc/added-directory &&
154 touch gitwc/added-directory/.placeholder &&
156 cd svnwc &&
157 svn_cmd add added-directory > /dev/null
158 ) &&
160 cd gitwc &&
161 git add added-directory
162 ) &&
163 (cd svnwc; svn info added-directory) \
164 > expected.info-added-directory &&
165 (cd gitwc; git svn info added-directory) \
166 > actual.info-added-directory &&
167 test_cmp_info expected.info-added-directory actual.info-added-directory
170 test_expect_success 'info --url added-directory' '
171 test "$(cd gitwc; git svn info --url added-directory)" \
172 = "$quoted_svnrepo/added-directory"
175 test_expect_success 'info added-symlink-file' "
177 cd gitwc &&
178 ln -s added-file added-symlink-file &&
179 git add added-symlink-file
180 ) &&
182 cd svnwc &&
183 ln -s added-file added-symlink-file &&
184 svn_cmd add added-symlink-file > /dev/null
185 ) &&
186 (cd svnwc; svn info added-symlink-file) \
187 > expected.info-added-symlink-file &&
188 (cd gitwc; git svn info added-symlink-file) \
189 > actual.info-added-symlink-file &&
190 test_cmp_info expected.info-added-symlink-file \
191 actual.info-added-symlink-file
194 test_expect_success 'info --url added-symlink-file' '
195 test "$(cd gitwc; git svn info --url added-symlink-file)" \
196 = "$quoted_svnrepo/added-symlink-file"
199 test_expect_success 'info added-symlink-directory' "
201 cd gitwc &&
202 ln -s added-directory added-symlink-directory &&
203 git add added-symlink-directory
204 ) &&
206 cd svnwc &&
207 ln -s added-directory added-symlink-directory &&
208 svn_cmd add added-symlink-directory > /dev/null
209 ) &&
210 (cd svnwc; svn info added-symlink-directory) \
211 > expected.info-added-symlink-directory &&
212 (cd gitwc; git svn info added-symlink-directory) \
213 > actual.info-added-symlink-directory &&
214 test_cmp_info expected.info-added-symlink-directory \
215 actual.info-added-symlink-directory
218 test_expect_success 'info --url added-symlink-directory' '
219 test "$(cd gitwc; git svn info --url added-symlink-directory)" \
220 = "$quoted_svnrepo/added-symlink-directory"
223 test_expect_success 'info deleted-file' "
225 cd gitwc &&
226 git rm -f file > /dev/null
227 ) &&
229 cd svnwc &&
230 svn_cmd rm --force file > /dev/null
231 ) &&
232 (cd svnwc; svn info file) >expected.info-deleted-file &&
233 (cd gitwc; git svn info file) >actual.info-deleted-file &&
234 test_cmp_info expected.info-deleted-file actual.info-deleted-file
237 test_expect_success 'info --url file (deleted)' '
238 test "$(cd gitwc; git svn info --url file)" \
239 = "$quoted_svnrepo/file"
242 test_expect_success 'info deleted-directory' "
244 cd gitwc &&
245 git rm -r -f directory > /dev/null
246 ) &&
248 cd svnwc &&
249 svn_cmd rm --force directory > /dev/null
250 ) &&
251 (cd svnwc; svn info directory) >expected.info-deleted-directory &&
252 (cd gitwc; git svn info directory) >actual.info-deleted-directory &&
253 test_cmp_info 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 = "$quoted_svnrepo/directory"
261 test_expect_success 'info deleted-symlink-file' "
263 cd gitwc &&
264 git rm -f symlink-file > /dev/null
265 ) &&
267 cd svnwc &&
268 svn_cmd rm --force symlink-file > /dev/null
269 ) &&
270 (cd svnwc; svn info symlink-file) >expected.info-deleted-symlink-file &&
271 (cd gitwc; git svn info symlink-file) >actual.info-deleted-symlink-file &&
272 test_cmp_info expected.info-deleted-symlink-file actual.info-deleted-symlink-file
275 test_expect_success 'info --url symlink-file (deleted)' '
276 test "$(cd gitwc; git svn info --url symlink-file)" \
277 = "$quoted_svnrepo/symlink-file"
280 test_expect_success 'info deleted-symlink-directory' "
282 cd gitwc &&
283 git rm -f symlink-directory > /dev/null
284 ) &&
286 cd svnwc &&
287 svn_cmd rm --force symlink-directory > /dev/null
288 ) &&
289 (cd svnwc; svn info symlink-directory) >expected.info-deleted-symlink-directory &&
290 (cd gitwc; git svn info symlink-directory) >actual.info-deleted-symlink-directory &&
291 test_cmp_info expected.info-deleted-symlink-directory actual.info-deleted-symlink-directory
294 test_expect_success 'info --url symlink-directory (deleted)' '
295 test "$(cd gitwc; git svn info --url symlink-directory)" \
296 = "$quoted_svnrepo/symlink-directory"
299 # NOTE: git does not have the concept of replaced objects,
300 # so we can't test for files in that state.
302 test_expect_success 'info unknown-file' "
303 echo two > gitwc/unknown-file &&
304 (cd gitwc; test_must_fail git svn info unknown-file) \
305 2> actual.info-unknown-file &&
306 grep unknown-file actual.info-unknown-file
309 test_expect_success 'info --url unknown-file' '
310 echo two > gitwc/unknown-file &&
311 (cd gitwc; test_must_fail git svn info --url unknown-file) \
312 2> actual.info-url-unknown-file &&
313 grep unknown-file actual.info-url-unknown-file
316 test_expect_success 'info unknown-directory' "
317 mkdir gitwc/unknown-directory svnwc/unknown-directory &&
318 (cd gitwc; test_must_fail git svn info unknown-directory) \
319 2> actual.info-unknown-directory &&
320 grep unknown-directory actual.info-unknown-directory
323 test_expect_success 'info --url unknown-directory' '
324 (cd gitwc; test_must_fail git svn info --url unknown-directory) \
325 2> actual.info-url-unknown-directory &&
326 grep unknown-directory actual.info-url-unknown-directory
329 test_expect_success 'info unknown-symlink-file' "
331 cd gitwc &&
332 ln -s unknown-file unknown-symlink-file
333 ) &&
334 (cd gitwc; test_must_fail git svn info unknown-symlink-file) \
335 2> actual.info-unknown-symlink-file &&
336 grep unknown-symlink-file actual.info-unknown-symlink-file
339 test_expect_success 'info --url unknown-symlink-file' '
340 (cd gitwc; test_must_fail git svn info --url unknown-symlink-file) \
341 2> actual.info-url-unknown-symlink-file &&
342 grep unknown-symlink-file actual.info-url-unknown-symlink-file
345 test_expect_success 'info unknown-symlink-directory' "
347 cd gitwc &&
348 ln -s unknown-directory unknown-symlink-directory
349 ) &&
350 (cd gitwc; test_must_fail git svn info unknown-symlink-directory) \
351 2> actual.info-unknown-symlink-directory &&
352 grep unknown-symlink-directory actual.info-unknown-symlink-directory
355 test_expect_success 'info --url unknown-symlink-directory' '
356 (cd gitwc; test_must_fail git svn info --url unknown-symlink-directory) \
357 2> actual.info-url-unknown-symlink-directory &&
358 grep unknown-symlink-directory actual.info-url-unknown-symlink-directory
361 test_done