git-svn info: implement info command
[git/wpalmer.git] / t / t9119-git-svn-info.sh
blobfbde8c81b58b5195816dfbcd9338959a192d5d68
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 .' "
49 (cd svnwc; svn info .) > expected.info-dot &&
50 (cd gitwc; git-svn info .) > actual.info-dot &&
51 git-diff expected.info-dot actual.info-dot
54 test_expect_success 'info file' "
55 (cd svnwc; svn info file) > expected.info-file &&
56 (cd gitwc; git-svn info file) > actual.info-file &&
57 git-diff expected.info-file actual.info-file
60 test_expect_success 'info directory' "
61 (cd svnwc; svn info directory) > expected.info-directory &&
62 (cd gitwc; git-svn info directory) > actual.info-directory &&
63 git-diff expected.info-directory actual.info-directory
66 test_expect_success 'info symlink-file' "
67 (cd svnwc; svn info symlink-file) > expected.info-symlink-file &&
68 (cd gitwc; git-svn info symlink-file) > actual.info-symlink-file &&
69 git-diff expected.info-symlink-file actual.info-symlink-file
72 test_expect_success 'info symlink-directory' "
73 (cd svnwc; svn info symlink-directory) \
74 > expected.info-symlink-directory &&
75 (cd gitwc; git-svn info symlink-directory) \
76 > actual.info-symlink-directory &&
77 git-diff expected.info-symlink-directory actual.info-symlink-directory
80 test_expect_success 'info added-file' "
81 echo two > gitwc/added-file &&
82 cd gitwc &&
83 git add added-file &&
84 cd .. &&
85 cp gitwc/added-file svnwc/added-file &&
86 ptouch gitwc/added-file svnwc/added-file &&
87 cd svnwc &&
88 svn add added-file > /dev/null &&
89 cd .. &&
90 (cd svnwc; svn info added-file) > expected.info-added-file &&
91 (cd gitwc; git-svn info added-file) > actual.info-added-file &&
92 git-diff expected.info-added-file actual.info-added-file
95 test_expect_success 'info added-directory' "
96 mkdir gitwc/added-directory svnwc/added-directory &&
97 ptouch gitwc/added-directory svnwc/added-directory &&
98 touch gitwc/added-directory/.placeholder &&
99 cd svnwc &&
100 svn add added-directory > /dev/null &&
101 cd .. &&
102 cd gitwc &&
103 git add added-directory &&
104 cd .. &&
105 (cd svnwc; svn info added-directory) \
106 > expected.info-added-directory &&
107 (cd gitwc; git-svn info added-directory) \
108 > actual.info-added-directory &&
109 git-diff expected.info-added-directory actual.info-added-directory
112 test_expect_success 'info added-symlink-file' "
113 cd gitwc &&
114 ln -s added-file added-symlink-file &&
115 git add added-symlink-file &&
116 cd .. &&
117 cd svnwc &&
118 ln -s added-file added-symlink-file &&
119 svn add added-symlink-file > /dev/null &&
120 cd .. &&
121 ptouch gitwc/added-symlink-file svnwc/added-symlink-file &&
122 (cd svnwc; svn info added-symlink-file) \
123 > expected.info-added-symlink-file &&
124 (cd gitwc; git-svn info added-symlink-file) \
125 > actual.info-added-symlink-file &&
126 git-diff expected.info-added-symlink-file \
127 actual.info-added-symlink-file
130 test_expect_success 'info added-symlink-directory' "
131 cd gitwc &&
132 ln -s added-directory added-symlink-directory &&
133 git add added-symlink-directory &&
134 cd .. &&
135 cd svnwc &&
136 ln -s added-directory added-symlink-directory &&
137 svn add added-symlink-directory > /dev/null &&
138 cd .. &&
139 ptouch gitwc/added-symlink-directory svnwc/added-symlink-directory &&
140 (cd svnwc; svn info added-symlink-directory) \
141 > expected.info-added-symlink-directory &&
142 (cd gitwc; git-svn info added-symlink-directory) \
143 > actual.info-added-symlink-directory &&
144 git-diff expected.info-added-symlink-directory \
145 actual.info-added-symlink-directory
148 # The next few tests replace the "Text Last Updated" value with a
149 # placeholder since git doesn't have a way to know the date that a
150 # now-deleted file was last checked out locally. Internally it
151 # simply reuses the Last Changed Date.
153 test_expect_success 'info deleted-file' "
154 cd gitwc &&
155 git rm -f file > /dev/null &&
156 cd .. &&
157 cd svnwc &&
158 svn rm --force file > /dev/null &&
159 cd .. &&
160 (cd svnwc; svn info file) |
161 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
162 > expected.info-deleted-file &&
163 (cd gitwc; git-svn info file) |
164 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
165 > actual.info-deleted-file &&
166 git-diff expected.info-deleted-file actual.info-deleted-file
169 test_expect_success 'info deleted-directory' "
170 cd gitwc &&
171 git rm -r -f directory > /dev/null &&
172 cd .. &&
173 cd svnwc &&
174 svn rm --force directory > /dev/null &&
175 cd .. &&
176 (cd svnwc; svn info directory) |
177 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
178 > expected.info-deleted-directory &&
179 (cd gitwc; git-svn info directory) |
180 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
181 > actual.info-deleted-directory &&
182 git-diff expected.info-deleted-directory actual.info-deleted-directory
185 test_expect_success 'info deleted-symlink-file' "
186 cd gitwc &&
187 git rm -f symlink-file > /dev/null &&
188 cd .. &&
189 cd svnwc &&
190 svn rm --force symlink-file > /dev/null &&
191 cd .. &&
192 (cd svnwc; svn info symlink-file) |
193 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
194 > expected.info-deleted-symlink-file &&
195 (cd gitwc; git-svn info symlink-file) |
196 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
197 > actual.info-deleted-symlink-file &&
198 git-diff expected.info-deleted-symlink-file \
199 actual.info-deleted-symlink-file
202 test_expect_success 'info deleted-symlink-directory' "
203 cd gitwc &&
204 git rm -f symlink-directory > /dev/null &&
205 cd .. &&
206 cd svnwc &&
207 svn rm --force symlink-directory > /dev/null &&
208 cd .. &&
209 (cd svnwc; svn info symlink-directory) |
210 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
211 > expected.info-deleted-symlink-directory &&
212 (cd gitwc; git-svn info symlink-directory) |
213 sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
214 > actual.info-deleted-symlink-directory &&
215 git-diff expected.info-deleted-symlink-directory \
216 actual.info-deleted-symlink-directory
219 # NOTE: git does not have the concept of replaced objects,
220 # so we can't test for files in that state.
222 test_expect_success 'info unknown-file' "
223 echo two > gitwc/unknown-file &&
224 cp gitwc/unknown-file svnwc/unknown-file &&
225 ptouch gitwc/unknown-file svnwc/unknown-file &&
226 (cd svnwc; svn info unknown-file) 2> expected.info-unknown-file &&
227 (cd gitwc; git-svn info unknown-file) 2> actual.info-unknown-file &&
228 git-diff expected.info-unknown-file actual.info-unknown-file
231 test_expect_success 'info unknown-directory' "
232 mkdir gitwc/unknown-directory svnwc/unknown-directory &&
233 ptouch gitwc/unknown-directory svnwc/unknown-directory &&
234 touch gitwc/unknown-directory/.placeholder &&
235 (cd svnwc; svn info unknown-directory) \
236 2> expected.info-unknown-directory &&
237 (cd gitwc; git-svn info unknown-directory) \
238 2> actual.info-unknown-directory &&
239 git-diff expected.info-unknown-directory actual.info-unknown-directory
242 test_expect_success 'info unknown-symlink-file' "
243 cd gitwc &&
244 ln -s unknown-file unknown-symlink-file &&
245 cd .. &&
246 cd svnwc &&
247 ln -s unknown-file unknown-symlink-file &&
248 cd .. &&
249 ptouch gitwc/unknown-symlink-file svnwc/unknown-symlink-file &&
250 (cd svnwc; svn info unknown-symlink-file) \
251 2> expected.info-unknown-symlink-file &&
252 (cd gitwc; git-svn info unknown-symlink-file) \
253 2> actual.info-unknown-symlink-file &&
254 git-diff expected.info-unknown-symlink-file \
255 actual.info-unknown-symlink-file
258 test_expect_success 'info unknown-symlink-directory' "
259 cd gitwc &&
260 ln -s unknown-directory unknown-symlink-directory &&
261 cd .. &&
262 cd svnwc &&
263 ln -s unknown-directory unknown-symlink-directory &&
264 cd .. &&
265 ptouch gitwc/unknown-symlink-directory \
266 svnwc/unknown-symlink-directory &&
267 (cd svnwc; svn info unknown-symlink-directory) \
268 2> expected.info-unknown-symlink-directory &&
269 (cd gitwc; git-svn info unknown-symlink-directory) \
270 2> actual.info-unknown-symlink-directory &&
271 git-diff expected.info-unknown-symlink-directory \
272 actual.info-unknown-symlink-directory
275 test_done