Code

git-archive: make compression level of ZIP archives configurable
authorRene Scharfe <rene.scharfe@lsrfire.ath.cx>
Sat, 9 Sep 2006 15:02:38 +0000 (17:02 +0200)
committerJunio C Hamano <junkio@cox.net>
Sat, 9 Sep 2006 20:39:57 +0000 (13:39 -0700)
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <junkio@cox.net>
archive.h
builtin-archive.c
builtin-zip-tree.c

index f3d344b65259fb7f4314944194e12ddba1129a4b..d8cca735d2dcbb13282be85e9e892c318bc53300 100644 (file)
--- 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 */
index 651d1bf6d916b40c38be8e0c9000a277fb667349..b94473755061f23f899517c801f809a3bedf7ee9 100644 (file)
@@ -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,
index 3afb7bde743ebd1fbdb80804c2cc995caa160969..4e796338af407929d3004dd0ea756a5b20ad659b 100644 (file)
@@ -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;
+}