From 854c4168e77a692dc198311f04bf31939355f2a3 Mon Sep 17 00:00:00 2001 From: Rene Scharfe Date: Sat, 9 Sep 2006 17:02:38 +0200 Subject: [PATCH] git-archive: make compression level of ZIP archives configurable Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- archive.h | 1 + builtin-archive.c | 11 +++++++++-- builtin-zip-tree.c | 13 +++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/archive.h b/archive.h index f3d344b652..d8cca735d2 100644 --- a/archive.h +++ b/archive.h @@ -42,5 +42,6 @@ extern void parse_pathspec_arg(const char **pathspec, */ extern int write_tar_archive(struct archiver_args *); extern int write_zip_archive(struct archiver_args *); +extern void *parse_extra_zip_args(int argc, const char **argv); #endif /* ARCHIVE_H */ diff --git a/builtin-archive.c b/builtin-archive.c index 651d1bf6d9..b944737550 100644 --- a/builtin-archive.c +++ b/builtin-archive.c @@ -15,8 +15,15 @@ static const char archive_usage[] = \ "git-archive --format= [--prefix=/] [] [path...]"; struct archiver archivers[] = { - { .name = "tar", .write_archive = write_tar_archive }, - { .name = "zip", .write_archive = write_zip_archive }, + { + .name = "tar", + .write_archive = write_tar_archive, + }, + { + .name = "zip", + .write_archive = write_zip_archive, + .parse_extra = parse_extra_zip_args, + }, }; static int run_remote_archiver(struct archiver *ar, int argc, diff --git a/builtin-zip-tree.c b/builtin-zip-tree.c index 3afb7bde74..4e796338af 100644 --- a/builtin-zip-tree.c +++ b/builtin-zip-tree.c @@ -379,3 +379,16 @@ int write_zip_archive(struct archiver_args *args) return 0; } + +void *parse_extra_zip_args(int argc, const char **argv) +{ + for (; argc > 0; argc--, argv++) { + const char *arg = argv[0]; + + if (arg[0] == '-' && isdigit(arg[1]) && arg[2] == '\0') + zlib_compression_level = arg[1] - '0'; + else + die("Unknown argument for zip format: %s", arg); + } + return NULL; +}