gitweb fix validating pg (page) parameter
[gitweb.git] / builtin-zip-tree.c
index 3afb7bde743ebd1fbdb80804c2cc995caa160969..52d4b7a17e39831964fe7c9c9c0cb374d0d61a62 100644 (file)
@@ -13,6 +13,7 @@
 static const char zip_tree_usage[] =
 "git-zip-tree [-0|...|-9] <tree-ish> [ <base> ]";
 
+static int verbose;
 static int zip_date;
 static int zip_time;
 
@@ -164,6 +165,8 @@ static int write_zip_entry(const unsigned char *sha1,
        crc = crc32(0, Z_NULL, 0);
 
        path = construct_path(base, baselen, filename, S_ISDIR(mode), &pathlen);
+       if (verbose)
+               fprintf(stderr, "%s\n", path);
        if (pathlen > 0xffff) {
                error("path too long (%d chars, SHA1: %s): %s", pathlen,
                      sha1_to_hex(sha1), path);
@@ -361,9 +364,10 @@ 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;
 
        if (args->base && plen > 0 && args->base[plen - 1] == '/') {
-               char *base = strdup(args->base);
+               char *base = xstrdup(args->base);
                int baselen = strlen(base);
 
                while (baselen > 0 && base[baselen - 1] == '/')
@@ -379,3 +383,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;
+}