summaryrefslogtreecommitdiff
path: root/t/t9119-git-svn-info.sh
blob: fbde8c81b58b5195816dfbcd9338959a192d5d68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
#!/bin/sh
#
# Copyright (c) 2007 David D. Kilzer
 
test_description='git-svn info'
 
. ./lib-git-svn.sh
 
ptouch() {
	perl -w -e '
		use strict;
		die "ptouch requires exactly 2 arguments" if @ARGV != 2;
		die "$ARGV[0] does not exist" if ! -e $ARGV[0];
		my @s = stat $ARGV[0];
		utime $s[8], $s[9], $ARGV[1];
	' "$1" "$2"
}
 
test_expect_success 'setup repository and import' "
	mkdir info &&
	cd info &&
		echo FIRST > A &&
		echo one > file &&
		ln -s file symlink-file &&
		mkdir directory &&
		touch directory/.placeholder &&
		ln -s directory symlink-directory &&
		svn import -m 'initial' . $svnrepo &&
	cd .. &&
	mkdir gitwc &&
	cd gitwc &&
		git-svn init $svnrepo &&
		git-svn fetch &&
	cd .. &&
	svn co $svnrepo svnwc &&
	ptouch svnwc/file gitwc/file &&
	ptouch svnwc/directory gitwc/directory &&
	ptouch svnwc/symlink-file gitwc/symlink-file &&
	ptouch svnwc/symlink-directory gitwc/symlink-directory
	"
 
test_expect_success 'info' "
	(cd svnwc; svn info) > expected.info &&
	(cd gitwc; git-svn info) > actual.info &&
	git-diff expected.info actual.info
	"
 
test_expect_success 'info .' "
	(cd svnwc; svn info .) > expected.info-dot &&
	(cd gitwc; git-svn info .) > actual.info-dot &&
	git-diff expected.info-dot actual.info-dot
	"
 
test_expect_success 'info file' "
	(cd svnwc; svn info file) > expected.info-file &&
	(cd gitwc; git-svn info file) > actual.info-file &&
	git-diff expected.info-file actual.info-file
	"
 
test_expect_success 'info directory' "
	(cd svnwc; svn info directory) > expected.info-directory &&
	(cd gitwc; git-svn info directory) > actual.info-directory &&
	git-diff expected.info-directory actual.info-directory
	"
 
test_expect_success 'info symlink-file' "
	(cd svnwc; svn info symlink-file) > expected.info-symlink-file &&
	(cd gitwc; git-svn info symlink-file) > actual.info-symlink-file &&
	git-diff expected.info-symlink-file actual.info-symlink-file
	"
 
test_expect_success 'info symlink-directory' "
	(cd svnwc; svn info symlink-directory) \
		> expected.info-symlink-directory &&
	(cd gitwc; git-svn info symlink-directory) \
		> actual.info-symlink-directory &&
	git-diff expected.info-symlink-directory actual.info-symlink-directory
	"
 
test_expect_success 'info added-file' "
	echo two > gitwc/added-file &&
	cd gitwc &&
		git add added-file &&
	cd .. &&
	cp gitwc/added-file svnwc/added-file &&
	ptouch gitwc/added-file svnwc/added-file &&
	cd svnwc &&
		svn add added-file > /dev/null &&
	cd .. &&
	(cd svnwc; svn info added-file) > expected.info-added-file &&
	(cd gitwc; git-svn info added-file) > actual.info-added-file &&
	git-diff expected.info-added-file actual.info-added-file
	"
 
test_expect_success 'info added-directory' "
	mkdir gitwc/added-directory svnwc/added-directory &&
	ptouch gitwc/added-directory svnwc/added-directory &&
	touch gitwc/added-directory/.placeholder &&
	cd svnwc &&
		svn add added-directory > /dev/null &&
	cd .. &&
	cd gitwc &&
		git add added-directory &&
	cd .. &&
	(cd svnwc; svn info added-directory) \
		> expected.info-added-directory &&
	(cd gitwc; git-svn info added-directory) \
		> actual.info-added-directory &&
	git-diff expected.info-added-directory actual.info-added-directory
	"
 
test_expect_success 'info added-symlink-file' "
	cd gitwc &&
		ln -s added-file added-symlink-file &&
		git add added-symlink-file &&
	cd .. &&
	cd svnwc &&
		ln -s added-file added-symlink-file &&
		svn add added-symlink-file > /dev/null &&
	cd .. &&
	ptouch gitwc/added-symlink-file svnwc/added-symlink-file &&
	(cd svnwc; svn info added-symlink-file) \
		> expected.info-added-symlink-file &&
	(cd gitwc; git-svn info added-symlink-file) \
		> actual.info-added-symlink-file &&
	git-diff expected.info-added-symlink-file \
		 actual.info-added-symlink-file
	"
 
test_expect_success 'info added-symlink-directory' "
	cd gitwc &&
		ln -s added-directory added-symlink-directory &&
		git add added-symlink-directory &&
	cd .. &&
	cd svnwc &&
		ln -s added-directory added-symlink-directory &&
		svn add added-symlink-directory > /dev/null &&
	cd .. &&
	ptouch gitwc/added-symlink-directory svnwc/added-symlink-directory &&
	(cd svnwc; svn info added-symlink-directory) \
		> expected.info-added-symlink-directory &&
	(cd gitwc; git-svn info added-symlink-directory) \
		> actual.info-added-symlink-directory &&
	git-diff expected.info-added-symlink-directory \
		 actual.info-added-symlink-directory
	"
 
# The next few tests replace the "Text Last Updated" value with a
# placeholder since git doesn't have a way to know the date that a
# now-deleted file was last checked out locally.  Internally it
# simply reuses the Last Changed Date.
 
test_expect_success 'info deleted-file' "
	cd gitwc &&
		git rm -f file > /dev/null &&
	cd .. &&
	cd svnwc &&
		svn rm --force file > /dev/null &&
	cd .. &&
	(cd svnwc; svn info file) |
	sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
		> expected.info-deleted-file &&
	(cd gitwc; git-svn info file) |
	sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
		> actual.info-deleted-file &&
	git-diff expected.info-deleted-file actual.info-deleted-file
	"
 
test_expect_success 'info deleted-directory' "
	cd gitwc &&
		git rm -r -f directory > /dev/null &&
	cd .. &&
	cd svnwc &&
		svn rm --force directory > /dev/null &&
	cd .. &&
	(cd svnwc; svn info directory) |
	sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
		> expected.info-deleted-directory &&
	(cd gitwc; git-svn info directory) |
	sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
		> actual.info-deleted-directory &&
	git-diff expected.info-deleted-directory actual.info-deleted-directory
	"
 
test_expect_success 'info deleted-symlink-file' "
	cd gitwc &&
		git rm -f symlink-file > /dev/null &&
	cd .. &&
	cd svnwc &&
		svn rm --force symlink-file > /dev/null &&
	cd .. &&
	(cd svnwc; svn info symlink-file) |
	sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
		> expected.info-deleted-symlink-file &&
	(cd gitwc; git-svn info symlink-file) |
	sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
		> actual.info-deleted-symlink-file &&
	git-diff expected.info-deleted-symlink-file \
		 actual.info-deleted-symlink-file
	"
 
test_expect_success 'info deleted-symlink-directory' "
	cd gitwc &&
		git rm -f symlink-directory > /dev/null &&
	cd .. &&
	cd svnwc &&
		svn rm --force symlink-directory > /dev/null &&
	cd .. &&
	(cd svnwc; svn info symlink-directory) |
	sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
		 > expected.info-deleted-symlink-directory &&
	(cd gitwc; git-svn info symlink-directory) |
	sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \
		 > actual.info-deleted-symlink-directory &&
	git-diff expected.info-deleted-symlink-directory \
		 actual.info-deleted-symlink-directory
	"
 
# NOTE: git does not have the concept of replaced objects,
# so we can't test for files in that state.
 
test_expect_success 'info unknown-file' "
	echo two > gitwc/unknown-file &&
	cp gitwc/unknown-file svnwc/unknown-file &&
	ptouch gitwc/unknown-file svnwc/unknown-file &&
	(cd svnwc; svn info unknown-file) 2> expected.info-unknown-file &&
	(cd gitwc; git-svn info unknown-file) 2> actual.info-unknown-file &&
	git-diff expected.info-unknown-file actual.info-unknown-file
	"
 
test_expect_success 'info unknown-directory' "
	mkdir gitwc/unknown-directory svnwc/unknown-directory &&
	ptouch gitwc/unknown-directory svnwc/unknown-directory &&
	touch gitwc/unknown-directory/.placeholder &&
	(cd svnwc; svn info unknown-directory) \
		2> expected.info-unknown-directory &&
	(cd gitwc; git-svn info unknown-directory) \
		2> actual.info-unknown-directory &&
	git-diff expected.info-unknown-directory actual.info-unknown-directory
	"
 
test_expect_success 'info unknown-symlink-file' "
	cd gitwc &&
		ln -s unknown-file unknown-symlink-file &&
	cd .. &&
	cd svnwc &&
		ln -s unknown-file unknown-symlink-file &&
	cd .. &&
	ptouch gitwc/unknown-symlink-file svnwc/unknown-symlink-file &&
	(cd svnwc; svn info unknown-symlink-file) \
		2> expected.info-unknown-symlink-file &&
	(cd gitwc; git-svn info unknown-symlink-file) \
		2> actual.info-unknown-symlink-file &&
	git-diff expected.info-unknown-symlink-file \
		 actual.info-unknown-symlink-file
	"
 
test_expect_success 'info unknown-symlink-directory' "
	cd gitwc &&
		ln -s unknown-directory unknown-symlink-directory &&
	cd .. &&
	cd svnwc &&
		ln -s unknown-directory unknown-symlink-directory &&
	cd .. &&
	ptouch gitwc/unknown-symlink-directory \
	       svnwc/unknown-symlink-directory &&
	(cd svnwc; svn info unknown-symlink-directory) \
		2> expected.info-unknown-symlink-directory &&
	(cd gitwc; git-svn info unknown-symlink-directory) \
		2> actual.info-unknown-symlink-directory &&
	git-diff expected.info-unknown-symlink-directory \
		 actual.info-unknown-symlink-directory
	"
 
test_done