@@ -31,6 +31,26 @@ GUNZIP=${GUNZIP:-gzip -d}
31
31
32
32
SUBSTFORMAT=%H%n
33
33
34
+ check_zip () {
35
+ zipfile=$1 .zip
36
+ listfile=$1 .lst
37
+ dir=$1
38
+ dir_with_prefix=$dir /$2
39
+
40
+ test_expect_success UNZIP " extract ZIP archive" "
41
+ (mkdir $dir && cd $dir && $UNZIP ../$zipfile )
42
+ "
43
+
44
+ test_expect_success UNZIP " validate filenames" "
45
+ (cd ${dir_with_prefix} a && find .) | sort >$listfile &&
46
+ test_cmp a.lst $listfile
47
+ "
48
+
49
+ test_expect_success UNZIP " validate file contents" "
50
+ diff -r a ${dir_with_prefix} a
51
+ "
52
+ }
53
+
34
54
test_expect_success \
35
55
' populate workdir' \
36
56
' mkdir a b c &&
@@ -181,10 +201,19 @@ test_expect_success \
181
201
test_cmp a/substfile2 g/prefix/a/substfile2
182
202
'
183
203
204
+ $UNZIP -v > /dev/null 2>&1
205
+ if [ $? -eq 127 ]; then
206
+ say " Skipping ZIP tests, because unzip was not found"
207
+ else
208
+ test_set_prereq UNZIP
209
+ fi
210
+
184
211
test_expect_success \
185
212
' git archive --format=zip' \
186
213
' git archive --format=zip HEAD >d.zip'
187
214
215
+ check_zip d
216
+
188
217
test_expect_success \
189
218
' git archive --format=zip in a bare repo' \
190
219
' (cd bare.git && git archive --format=zip HEAD) >d1.zip'
@@ -207,55 +236,25 @@ test_expect_success 'git archive with --output, override inferred format' '
207
236
test_cmp b.tar d4.zip
208
237
'
209
238
210
- $UNZIP -v > /dev/null 2>&1
211
- if [ $? -eq 127 ]; then
212
- say " Skipping ZIP tests, because unzip was not found"
213
- else
214
- test_set_prereq UNZIP
215
- fi
216
-
217
- test_expect_success UNZIP \
218
- ' extract ZIP archive' \
219
- ' (mkdir d && cd d && $UNZIP ../d.zip)'
220
-
221
- test_expect_success UNZIP \
222
- ' validate filenames' \
223
- ' (cd d/a && find .) | sort >d.lst &&
224
- test_cmp a.lst d.lst'
225
-
226
- test_expect_success UNZIP \
227
- ' validate file contents' \
228
- ' diff -r a d/a'
229
-
230
239
test_expect_success \
231
240
' git archive --format=zip with prefix' \
232
241
' git archive --format=zip --prefix=prefix/ HEAD >e.zip'
233
242
234
- test_expect_success UNZIP \
235
- ' extract ZIP archive with prefix' \
236
- ' (mkdir e && cd e && $UNZIP ../e.zip)'
243
+ check_zip e prefix/
237
244
238
- test_expect_success UNZIP \
239
- ' validate filenames with prefix ' \
240
- ' (cd e/prefix/a && find .) | sort >e.lst &&
241
- test_cmp a.lst e.lst '
245
+ test_expect_success ' git archive -0 --format=zip on large files ' '
246
+ test_config core.bigfilethreshold 1 &&
247
+ git archive -0 --format=zip HEAD >large.zip
248
+ '
242
249
243
- test_expect_success UNZIP \
244
- ' validate file contents with prefix' \
245
- ' diff -r a e/prefix/a'
250
+ check_zip large
246
251
247
- test_expect_success UNZIP ' git archive -0 --format=zip on large files' '
248
- test_config core.bigfilethreshold 1 &&
249
- git archive -0 --format=zip HEAD >large.zip &&
250
- (mkdir large && cd large && $UNZIP ../large.zip)
252
+ test_expect_success ' git archive --format=zip on large files' '
253
+ test_config core.bigfilethreshold 1 &&
254
+ git archive --format=zip HEAD >large-compressed.zip
251
255
'
252
256
253
- test_expect_success UNZIP ' git archive --format=zip on large files' '
254
- test_config core.bigfilethreshold 1 &&
255
- git archive --format=zip HEAD >large-compressed.zip &&
256
- (mkdir large-compressed && cd large-compressed && $UNZIP ../large-compressed.zip) &&
257
- test_cmp large-compressed/a/bin/sh large/a/bin/sh
258
- '
257
+ check_zip large-compressed
259
258
260
259
test_expect_success \
261
260
' git archive --list outside of a git repo' \
0 commit comments