X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=archive-zip.c;h=74e30f6205f41112dc2bafe9371a790aca55f70c;hb=4f337e24662f07513fd6e8388f27f13dbe44cadc;hp=3cbf6bb8ac4045803140ca5019126015e817155e;hpb=5610c6e381f54b7733d344010edc6ed20ec15761;p=git.git diff --git a/archive-zip.c b/archive-zip.c index 3cbf6bb8a..74e30f620 100644 --- a/archive-zip.c +++ b/archive-zip.c @@ -12,6 +12,7 @@ static int verbose; static int zip_date; static int zip_time; +static const struct commit *commit; static unsigned char *zip_dir; static unsigned int zip_dir_size; @@ -182,7 +183,7 @@ static int write_zip_entry(const unsigned char *sha1, goto out; } - if (S_ISDIR(mode) || S_ISDIRLNK(mode)) { + if (S_ISDIR(mode) || S_ISGITLINK(mode)) { method = 0; attr2 = 16; result = (S_ISDIR(mode) ? READ_TREE_RECURSIVE : 0); @@ -191,11 +192,13 @@ 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; - buffer = convert_sha1_file(path, sha1, mode, &type, &size); + buffer = sha1_file_to_archive(path, sha1, mode, &type, &size, + commit); if (!buffer) die("cannot read %s", sha1_to_hex(sha1)); crc = crc32(crc, buffer, size); @@ -229,7 +232,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); @@ -316,6 +320,7 @@ int write_zip_archive(struct archiver_args *args) zip_dir = xmalloc(ZIP_DIRECTORY_MIN_SIZE); zip_dir_size = ZIP_DIRECTORY_MIN_SIZE; verbose = args->verbose; + commit = args->commit; if (args->base && plen > 0 && args->base[plen - 1] == '/') { char *base = xstrdup(args->base);