@@ -24,6 +24,11 @@ static unsigned int max_creator_version;
24
24
#define ZIP_STREAM (1 << 3)
25
25
#define ZIP_UTF8 (1 << 11)
26
26
27
+ enum zip_method {
28
+ ZIP_METHOD_STORE = 0 ,
29
+ ZIP_METHOD_DEFLATE = 8
30
+ };
31
+
27
32
struct zip_local_header {
28
33
unsigned char magic [4 ];
29
34
unsigned char version [2 ];
@@ -291,7 +296,7 @@ static int write_zip_entry(struct archiver_args *args,
291
296
unsigned long attr2 ;
292
297
unsigned long compressed_size ;
293
298
unsigned long crc ;
294
- int method ;
299
+ enum zip_method method ;
295
300
unsigned char * out ;
296
301
void * deflated = NULL ;
297
302
void * buffer ;
@@ -320,7 +325,7 @@ static int write_zip_entry(struct archiver_args *args,
320
325
}
321
326
322
327
if (S_ISDIR (mode ) || S_ISGITLINK (mode )) {
323
- method = 0 ;
328
+ method = ZIP_METHOD_STORE ;
324
329
attr2 = 16 ;
325
330
out = NULL ;
326
331
size = 0 ;
@@ -330,13 +335,13 @@ static int write_zip_entry(struct archiver_args *args,
330
335
enum object_type type = oid_object_info (args -> repo , oid ,
331
336
& size );
332
337
333
- method = 0 ;
338
+ method = ZIP_METHOD_STORE ;
334
339
attr2 = S_ISLNK (mode ) ? ((mode | 0777 ) << 16 ) :
335
340
(mode & 0111 ) ? ((mode ) << 16 ) : 0 ;
336
341
if (S_ISLNK (mode ) || (mode & 0111 ))
337
342
creator_version = 0x0317 ;
338
343
if (S_ISREG (mode ) && args -> compression_level != 0 && size > 0 )
339
- method = 8 ;
344
+ method = ZIP_METHOD_DEFLATE ;
340
345
341
346
if (S_ISREG (mode ) && type == OBJ_BLOB && !args -> convert &&
342
347
size > big_file_threshold ) {
@@ -358,7 +363,7 @@ static int write_zip_entry(struct archiver_args *args,
358
363
buffer , size );
359
364
out = buffer ;
360
365
}
361
- compressed_size = (method == 0 ) ? size : 0 ;
366
+ compressed_size = (method == ZIP_METHOD_STORE ) ? size : 0 ;
362
367
} else {
363
368
return error (_ ("unsupported file mode: 0%o (SHA1: %s)" ), mode ,
364
369
oid_to_hex (oid ));
@@ -367,13 +372,13 @@ static int write_zip_entry(struct archiver_args *args,
367
372
if (creator_version > max_creator_version )
368
373
max_creator_version = creator_version ;
369
374
370
- if (buffer && method == 8 ) {
375
+ if (buffer && method == ZIP_METHOD_DEFLATE ) {
371
376
out = deflated = zlib_deflate_raw (buffer , size ,
372
377
args -> compression_level ,
373
378
& compressed_size );
374
379
if (!out || compressed_size >= size ) {
375
380
out = buffer ;
376
- method = 0 ;
381
+ method = ZIP_METHOD_STORE ;
377
382
compressed_size = size ;
378
383
}
379
384
}
@@ -420,7 +425,7 @@ static int write_zip_entry(struct archiver_args *args,
420
425
zip_offset += ZIP64_EXTRA_SIZE ;
421
426
}
422
427
423
- if (stream && method == 0 ) {
428
+ if (stream && method == ZIP_METHOD_STORE ) {
424
429
unsigned char buf [STREAM_BUFFER_SIZE ];
425
430
ssize_t readlen ;
426
431
@@ -443,7 +448,7 @@ static int write_zip_entry(struct archiver_args *args,
443
448
zip_offset += compressed_size ;
444
449
445
450
write_zip_data_desc (size , compressed_size , crc );
446
- } else if (stream && method == 8 ) {
451
+ } else if (stream && method == ZIP_METHOD_DEFLATE ) {
447
452
unsigned char buf [STREAM_BUFFER_SIZE ];
448
453
ssize_t readlen ;
449
454
git_zstream zstream ;
0 commit comments