diff options
author | Franck Bui-Huu <vagabon.xyz@gmail.com> | 2006-09-07 15:12:04 +0200 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-09-09 11:57:37 -0700 |
commit | ec06bff5e6f76b46c22a3b2c97452568f088fa3c (patch) | |
tree | 5002cdb4a2b53f2767ce36fa8b1bde59803f049a /builtin-zip-tree.c | |
parent | git-archive: wire up TAR format. (diff) | |
download | tgif-ec06bff5e6f76b46c22a3b2c97452568f088fa3c.tar.xz |
git-archive: wire up ZIP format.
Again, this is based on Rene Scharfe's earlier patch, but uses
the archiver support introduced by the previous patch.
Signed-off-by: Franck Bui-Huu <vagabon.xyz@gmail.com>
Acked-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-zip-tree.c')
-rw-r--r-- | builtin-zip-tree.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/builtin-zip-tree.c b/builtin-zip-tree.c index 1c1f6830c1..3afb7bde74 100644 --- a/builtin-zip-tree.c +++ b/builtin-zip-tree.c @@ -8,6 +8,7 @@ #include "tree.h" #include "quote.h" #include "builtin.h" +#include "archive.h" static const char zip_tree_usage[] = "git-zip-tree [-0|...|-9] <tree-ish> [ <base> ]"; @@ -351,3 +352,30 @@ int cmd_zip_tree(int argc, const char **argv, const char *prefix) return 0; } + +int write_zip_archive(struct archiver_args *args) +{ + int plen = strlen(args->base); + + dos_time(&args->time, &zip_date, &zip_time); + + zip_dir = xmalloc(ZIP_DIRECTORY_MIN_SIZE); + zip_dir_size = ZIP_DIRECTORY_MIN_SIZE; + + if (args->base && plen > 0 && args->base[plen - 1] == '/') { + char *base = strdup(args->base); + int baselen = strlen(base); + + while (baselen > 0 && base[baselen - 1] == '/') + base[--baselen] = '\0'; + write_zip_entry(args->tree->object.sha1, "", 0, base, 040777, 0); + free(base); + } + read_tree_recursive(args->tree, args->base, plen, 0, + args->pathspec, write_zip_entry); + write_zip_trailer(args->commit_sha1); + + free(zip_dir); + + return 0; +} |