[PATCH] preserve executable bits in zip archives

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git@...>
Date: Sunday, September 16, 2007 - 1:07 pm

Correct `git-archive --format=3Dzip' 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 =3D 0;
 	} else if (S_ISREG(mode) || S_ISLNK(mode)) {
 		method =3D 0;
-		attr2 =3D S_ISLNK(mode) ? ((mode | 0777) << 16) : 0;
+		attr2 =3D S_ISLNK(mode) ? ((mode | 0777) << 16) :=20
+			(mode & 0111) ? ((mode) << 16) : 0;
 		if (S_ISREG(mode) && zlib_compression_level !=3D 0)
 			method =3D 8;
 		result =3D 0;
@@ -229,7 +230,8 @@ static int write_zip_entry(const unsigned char *sha1,
 	}
=20
 	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);
--=20
1.5.3.1
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] preserve executable bits in zip archives, Dmitry Potapov, (Sun Sep 16, 1:07 pm)