Skip to content

Commit 76bf8d0

Browse files
dmpotgitster
authored andcommitted
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>
1 parent e349026 commit 76bf8d0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

archive-zip.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ static int write_zip_entry(const unsigned char *sha1,
192192
compressed_size = 0;
193193
} else if (S_ISREG(mode) || S_ISLNK(mode)) {
194194
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;
196197
if (S_ISREG(mode) && zlib_compression_level != 0)
197198
method = 8;
198199
result = 0;
@@ -231,7 +232,8 @@ static int write_zip_entry(const unsigned char *sha1,
231232
}
232233

233234
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);
235237
copy_le16(dirent.version, 10);
236238
copy_le16(dirent.flags, 0);
237239
copy_le16(dirent.compression_method, method);

0 commit comments

Comments
 (0)