summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archive.h1
-rw-r--r--builtin-archive.c11
-rw-r--r--builtin-zip-tree.c13
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=<fmt> [--prefix=<prefix>/] [<extra>] <tree-ish> [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;
+}