summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: efd8696)
raw | patch | inline | side by side (parent: efd8696)
author | Franck Bui-Huu <vagabon.xyz@gmail.com> | |
Thu, 7 Sep 2006 13:12:04 +0000 (15:12 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 9 Sep 2006 18:57:37 +0000 (11:57 -0700) |
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>
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>
archive.h | patch | blob | history | |
builtin-archive.c | patch | blob | history | |
builtin-zip-tree.c | patch | blob | history |
diff --git a/archive.h b/archive.h
index 5c3f29b8df2722805c5009c99c64a39191f14fb1..f3d344b65259fb7f4314944194e12ddba1129a4b 100644 (file)
--- a/archive.h
+++ b/archive.h
* Archive-format specific backends.
*/
extern int write_tar_archive(struct archiver_args *);
+extern int write_zip_archive(struct archiver_args *);
#endif /* ARCHIVE_H */
diff --git a/builtin-archive.c b/builtin-archive.c
index c6423b9c48b4d84269343e30c790d5c82dc9cd83..651d1bf6d916b40c38be8e0c9000a277fb667349 100644 (file)
--- a/builtin-archive.c
+++ b/builtin-archive.c
struct archiver archivers[] = {
{ .name = "tar", .write_archive = write_tar_archive },
+ { .name = "zip", .write_archive = write_zip_archive },
};
static int run_remote_archiver(struct archiver *ar, int argc,
diff --git a/builtin-zip-tree.c b/builtin-zip-tree.c
index 1c1f6830c1a8b9303eec3b1c11cfb1805d3049e4..3afb7bde743ebd1fbdb80804c2cc995caa160969 100644 (file)
--- a/builtin-zip-tree.c
+++ b/builtin-zip-tree.c
#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> ]";
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;
+}