summaryrefslogtreecommitdiff
path: root/archive-zip.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2015-08-22 19:06:31 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-08-28 15:52:22 (GMT)
commit0f747f9d37e2b3d7a454029dfcf0065e6914e995 (patch)
tree98d9c11a2b7db605b2f6266b3a80e22c0b57eb9c /archive-zip.c
parent19ee29401dfc414924f335c21ef9880513f3c58d (diff)
downloadgit-0f747f9d37e2b3d7a454029dfcf0065e6914e995.zip
git-0f747f9d37e2b3d7a454029dfcf0065e6914e995.tar.gz
git-0f747f9d37e2b3d7a454029dfcf0065e6914e995.tar.bz2
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>
Diffstat (limited to 'archive-zip.c')
-rw-r--r--archive-zip.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/archive-zip.c b/archive-zip.c
index ffb3535..df004de 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -223,6 +223,7 @@ static int write_zip_entry(struct archiver_args *args,
unsigned long size;
int is_binary = -1;
const char *path_without_prefix = path + args->baselen;
+ unsigned int creator_version = 0;
crc = crc32(0, NULL, 0);
@@ -251,6 +252,8 @@ static int write_zip_entry(struct archiver_args *args,
method = 0;
attr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) :
(mode & 0111) ? ((mode) << 16) : 0;
+ if (S_ISLNK(mode) || (mode & 0111))
+ creator_version = 0x0317;
if (S_ISREG(mode) && args->compression_level != 0 && size > 0)
method = 8;
@@ -303,8 +306,7 @@ static int write_zip_entry(struct archiver_args *args,
}
copy_le32(dirent.magic, 0x02014b50);
- copy_le16(dirent.creator_version,
- S_ISLNK(mode) || (S_ISREG(mode) && (mode & 0111)) ? 0x0317 : 0);
+ copy_le16(dirent.creator_version, creator_version);
copy_le16(dirent.version, 10);
copy_le16(dirent.flags, flags);
copy_le16(dirent.compression_method, method);