archive-zip: use a local variable to store the creator version
Use a simpler conditional right next to the code which makes a higher creator version necessary -- namely symlink handling and support for executable files -- instead of a long line with a ternary operator. The resulting code has more lines but is simpler and allows reuse of the value easily. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Aug 22, 2015 at 21:06 UTC
0f747f9d37e2b3d7a454029dfcf0065e6914e995
1 file changed
+4
-2
archive-zip.c
+4
-2
@@ -223,6 +223,7 @@ static int write_zip_entry(struct archiver_args *args,
223
unsigned long size;
224
int is_binary = -1;
225
const char *path_without_prefix = path + args->baselen;
226
+ unsigned int creator_version = 0;
227
228
crc = crc32(0, NULL, 0);
229
@@ -251,6 +252,8 @@ static int write_zip_entry(struct archiver_args *args,
252
method = 0;
253
attr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) :
254
(mode & 0111) ? ((mode) << 16) : 0;
255
+ if (S_ISLNK(mode) || (mode & 0111))
256
+ creator_version = 0x0317;
257
if (S_ISREG(mode) && args->compression_level != 0 && size > 0)
258
method = 8;
259
@@ -303,8 +306,7 @@ static int write_zip_entry(struct archiver_args *args,
306
}
307
308
copy_le32(dirent.magic, 0x02014b50);
306
- copy_le16(dirent.creator_version,
307
- S_ISLNK(mode) || (S_ISREG(mode) && (mode & 0111)) ? 0x0317 : 0);
309
+ copy_le16(dirent.creator_version, creator_version);
310
copy_le16(dirent.version, 10);
311
copy_le16(dirent.flags, flags);
312
copy_le16(dirent.compression_method, method);