diff --git a/archive-zip.c b/archive-zip.c
index 74e30f6205f41112dc2bafe9371a790aca55f70c..d18254c5c00a0a491afa1d8517d08c747dbad395 100644 (file)
--- a/archive-zip.c
+++ b/archive-zip.c
static int zip_date;
static int zip_time;
static const struct commit *commit;
static int zip_date;
static int zip_time;
static const struct commit *commit;
+static size_t base_len;
static unsigned char *zip_dir;
static unsigned int zip_dir_size;
static unsigned char *zip_dir;
static unsigned int zip_dir_size;
return path;
}
return path;
}
-static int write_zip_entry(const unsigned char *sha1,
- const char *base, int baselen,
- const char *filename, unsigned mode, int stage)
+static int write_zip_entry(const unsigned char *sha1, const char *base,
+ int baselen, const char *filename, unsigned mode, int stage,
+ void *context)
{
struct zip_local_header header;
struct zip_dir_header dirent;
{
struct zip_local_header header;
struct zip_dir_header dirent;
crc = crc32(0, NULL, 0);
path = construct_path(base, baselen, filename, S_ISDIR(mode), &pathlen);
crc = crc32(0, NULL, 0);
path = construct_path(base, baselen, filename, S_ISDIR(mode), &pathlen);
+ if (is_archive_path_ignored(path + base_len))
+ return 0;
if (verbose)
fprintf(stderr, "%s\n", path);
if (pathlen > 0xffff) {
if (verbose)
fprintf(stderr, "%s\n", path);
if (pathlen > 0xffff) {
if (S_ISREG(mode) && zlib_compression_level != 0)
method = 8;
result = 0;
if (S_ISREG(mode) && zlib_compression_level != 0)
method = 8;
result = 0;
- buffer = sha1_file_to_archive(path, sha1, mode, &type, &size,
- commit);
+ buffer = sha1_file_to_archive(path + base_len, sha1, mode,
+ &type, &size, commit);
if (!buffer)
die("cannot read %s", sha1_to_hex(sha1));
crc = crc32(crc, buffer, size);
if (!buffer)
die("cannot read %s", sha1_to_hex(sha1));
crc = crc32(crc, buffer, size);
int write_zip_archive(struct archiver_args *args)
{
int write_zip_archive(struct archiver_args *args)
{
- int plen = strlen(args->base);
-
dos_time(&args->time, &zip_date, &zip_time);
zip_dir = xmalloc(ZIP_DIRECTORY_MIN_SIZE);
zip_dir_size = ZIP_DIRECTORY_MIN_SIZE;
verbose = args->verbose;
commit = args->commit;
dos_time(&args->time, &zip_date, &zip_time);
zip_dir = xmalloc(ZIP_DIRECTORY_MIN_SIZE);
zip_dir_size = ZIP_DIRECTORY_MIN_SIZE;
verbose = args->verbose;
commit = args->commit;
+ base_len = args->baselen;
- if (args->base && plen > 0 && args->base[plen - 1] == '/') {
+ if (args->baselen > 0 && args->base[args->baselen - 1] == '/') {
char *base = xstrdup(args->base);
int baselen = strlen(base);
while (baselen > 0 && base[baselen - 1] == '/')
base[--baselen] = '\0';
char *base = xstrdup(args->base);
int baselen = strlen(base);
while (baselen > 0 && base[baselen - 1] == '/')
base[--baselen] = '\0';
- write_zip_entry(args->tree->object.sha1, "", 0, base, 040777, 0);
+ write_zip_entry(args->tree->object.sha1, "", 0, base, 040777,
+ 0, NULL);
free(base);
}
free(base);
}
- read_tree_recursive(args->tree, args->base, plen, 0,
- args->pathspec, write_zip_entry);
+ read_tree_recursive(args->tree, args->base, args->baselen, 0,
+ args->pathspec, write_zip_entry, NULL);
write_zip_trailer(args->commit_sha1);
free(zip_dir);
write_zip_trailer(args->commit_sha1);
free(zip_dir);