@matheusbsbs / matheus-bagliano / commits / 76bf8d0e0a
Fork 0

preserve executable bits in zip archives

Correct `git-archive --format=zip' command to preserve executable bits in zip archives. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Dmitry Potapov committed Sep 16, 2007 at 21:07 UTC 76bf8d0e0ad0840395471fd862bd2cdad095345d
1 file changed +4 -2
archive-zip.c
+4 -2
@@ -192,7 +192,8 @@ static int write_zip_entry(const unsigned char *sha1,
192 compressed_size = 0;
193 } else if (S_ISREG(mode) || S_ISLNK(mode)) {
194 method = 0;
195 - attr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) : 0;
195 + attr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) :
196 + (mode & 0111) ? ((mode) << 16) : 0;
197 if (S_ISREG(mode) && zlib_compression_level != 0)
198 method = 8;
199 result = 0;
@@ -231,7 +232,8 @@ static int write_zip_entry(const unsigned char *sha1,
232 }
233
234 copy_le32(dirent.magic, 0x02014b50);
234 - copy_le16(dirent.creator_version, S_ISLNK(mode) ? 0x0317 : 0);
235 + copy_le16(dirent.creator_version,
236 + S_ISLNK(mode) || (S_ISREG(mode) && (mode & 0111)) ? 0x0317 : 0);
237 copy_le16(dirent.version, 10);
238 copy_le16(dirent.flags, 0);
239 copy_le16(dirent.compression_method, method);