{"thread":{"id":"9879","subject":"[PATCH] preserve executable bits in zip archives","startedAt":"2007-09-16T17:07:38Z","lastAt":"2007-09-16T17:07:38Z","messageCount":1,"participants":["Dmitry Potapov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"53195","messageId":"20070916170738.GA30175@potapov","threadId":"9879","inReplyTo":null,"subject":"[PATCH] preserve executable bits in zip archives","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2007-09-16T17:07:38Z","receivedAt":"2007-09-16T17:07:38Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"Correct `git-archive --format=zip' command to preserve executable bits in\nzip archives.\n\n---\n archive-zip.c |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/archive-zip.c b/archive-zip.c\nindex 444e162..5f9b7e6 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -191,7 +191,8 @@ static int write_zip_entry(const unsigned char *sha1,\n \t\tcompressed_size = 0;\n \t} else if (S_ISREG(mode) || S_ISLNK(mode)) {\n \t\tmethod = 0;\n-\t\tattr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) : 0;\n+\t\tattr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) : \n+\t\t\t(mode & 0111) ? ((mode) << 16) : 0;\n \t\tif (S_ISREG(mode) && zlib_compression_level != 0)\n \t\t\tmethod = 8;\n \t\tresult = 0;\n@@ -229,7 +230,8 @@ static int write_zip_entry(const unsigned char *sha1,\n \t}\n \n \tcopy_le32(dirent.magic, 0x02014b50);\n-\tcopy_le16(dirent.creator_version, S_ISLNK(mode) ? 0x0317 : 0);\n+\tcopy_le16(dirent.creator_version,\n+\t\tS_ISLNK(mode) || (S_ISREG(mode) && (mode & 0111)) ? 0x0317 : 0);\n \tcopy_le16(dirent.version, 10);\n \tcopy_le16(dirent.flags, 0);\n \tcopy_le16(dirent.compression_method, method);\n-- \n1.5.3.1\n\n"}]}