From: "René Scharfe" <l.s.r@web.de>
To: Johannes Schauer <josch@debian.org>, git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 2/3] archive-zip: use a local variable to store the creator version
Date: Sat, 22 Aug 2015 21:06:31 +0200 [thread overview]
Message-ID: <55D8C837.6070601@web.de> (raw)
In-Reply-To: <20150813022545.30116.44787@localhost>
Use a simpler conditional right next to the code which makes a higher
creator version necessary -- namely symlink handling and support for
executable files -- instead of a long line with a ternary operator.
The resulting code has more lines but is simpler and allows reuse of
the value easily.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
archive-zip.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/archive-zip.c b/archive-zip.c
index ae3d67f..2a76156 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -223,6 +223,7 @@ static int write_zip_entry(struct archiver_args *args,
unsigned long size;
int is_binary = -1;
const char *path_without_prefix = path + args->baselen;
+ unsigned int creator_version = 0;
crc = crc32(0, NULL, 0);
@@ -251,6 +252,8 @@ static int write_zip_entry(struct archiver_args *args,
method = 0;
attr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) :
(mode & 0111) ? ((mode) << 16) : 0;
+ if (S_ISLNK(mode) || (mode & 0111))
+ creator_version = 0x0317;
if (S_ISREG(mode) && args->compression_level != 0 && size > 0)
method = 8;
@@ -303,8 +306,7 @@ static int write_zip_entry(struct archiver_args *args,
}
copy_le32(dirent.magic, 0x02014b50);
- copy_le16(dirent.creator_version,
- S_ISLNK(mode) || (S_ISREG(mode) && (mode & 0111)) ? 0x0317 : 0);
+ copy_le16(dirent.creator_version, creator_version);
copy_le16(dirent.version, 10);
copy_le16(dirent.flags, flags);
copy_le16(dirent.compression_method, method);
--
2.5.0
next prev parent reply other threads:[~2015-08-22 19:06 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-11 10:40 bug: git-archive does not use the zip64 extension for archives with more than 16k entries Johannes Schauer
2015-08-12 19:40 ` René Scharfe
2015-08-13 2:25 ` Johannes Schauer
2015-08-22 19:06 ` [PATCH 1/3] t5004: test ZIP archives with many entries René Scharfe
2015-08-23 5:54 ` Eric Sunshine
2015-08-23 9:29 ` "René Scharfe"
2015-08-23 9:35 ` Eric Sunshine mail delivery failure René Scharfe
2015-08-23 17:16 ` Johannes Löthberg
2015-08-23 18:24 ` Eric Sunshine
[not found] ` <CA+EOSBmk2cdQe3owaXgkYAgTZqpUFa=J8g5FYq28-=VhDcJ4EA@mail.gmail.com>
2015-08-23 18:48 ` Eric Sunshine
2015-08-23 18:57 ` Eric Sunshine
2015-08-23 17:45 ` [PATCH 1/3] t5004: test ZIP archives with many entries Eric Sunshine
2015-08-28 15:45 ` Junio C Hamano
2015-08-28 15:57 ` Junio C Hamano
2015-08-28 16:47 ` Eric Sunshine
2015-08-22 19:06 ` René Scharfe [this message]
2015-08-22 19:06 ` [PATCH 3/3] archive-zip: support more than 65535 entries René Scharfe
2015-08-15 8:40 ` bug: git-archive does not use the zip64 extension for archives with more than 16k entries Duy Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55D8C837.6070601@web.de \
--to=l.s.r@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=josch@debian.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.