Skip to content

Commit

Permalink
git-archive: make compression level of ZIP archives configurable
Browse files Browse the repository at this point in the history
Signed-off-by: Rene Scharfe <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
Rene Scharfe authored and Junio C Hamano committed Sep 9, 2006
1 parent 39345a2 commit 854c416
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
11 changes: 9 additions & 2 deletions builtin-archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions builtin-zip-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 854c416

Please sign in to comment.