git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] preserve executable bits in zip archives

From
Dmitry Potapov <dpotapov@gmail.com>
Date
Sep 16, 2007, 17:07 UTC
Message-ID
<20070916170738.GA30175@potapov>

Correct `git-archive --format=zip' command to preserve executable bits in zip archives.

---
 archive-zip.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/archive-zip.c b/archive-zip.c
index 444e162..5f9b7e6 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -191,7 +191,8 @@ static int write_zip_entry(const unsigned char *sha1,
 		compressed_size = 0;
 	} else if (S_ISREG(mode) || S_ISLNK(mode)) {
 		method = 0;
-		attr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) : 0;
+		attr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) : 
+			(mode & 0111) ? ((mode) << 16) : 0;
 		if (S_ISREG(mode) && zlib_compression_level != 0)
 			method = 8;
 		result = 0;
@@ -229,7 +230,8 @@ static int write_zip_entry(const unsigned char *sha1,
 	}
 
 	copy_le32(dirent.magic, 0x02014b50);
-	copy_le16(dirent.creator_version, S_ISLNK(mode) ? 0x0317 : 0);
+	copy_le16(dirent.creator_version,
+		S_ISLNK(mode) || (S_ISREG(mode) && (mode & 0111)) ? 0x0317 : 0);
 	copy_le16(dirent.version, 10);
 	copy_le16(dirent.flags, 0);
 	copy_le16(dirent.compression_method, method);
-- 
1.5.3.1
Message 1 of 1 in “preserve executable bits in zip archives”
  1. preserve executable bits in zip archivesDmitry Potapov, Sep 16, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.