path: root/archive-zip.c
diff options
authorJeff King <>2011-06-22 01:23:33 (GMT)
committerJunio C Hamano <>2011-06-22 18:12:35 (GMT)
commit13e0f88d4aba326da9217c225d6ab5e642eb611d (patch)
treeaf7e13e62c420620946b152ea383f680d6105a94 /archive-zip.c
parent40e7629194c79e72009b5b8e98cce65921b0faf2 (diff)
archive: refactor list of archive formats
Most of the tar and zip code was nicely split out into two abstracted files which knew only about their specific formats. The entry point to this code was a single "write archive" function. However, as these basic formats grow more complex (e.g., by handling multiple file extensions and format names), a static list of the entry point functions won't be enough. Instead, let's provide a way for the tar and zip code to tell the main archive code what they support by registering archiver names and functions. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'archive-zip.c')
1 files changed, 12 insertions, 1 deletions
diff --git a/archive-zip.c b/archive-zip.c
index cf28504..a776d83 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -261,7 +261,7 @@ static void dos_time(time_t *time, int *dos_date, int *dos_time)
*dos_time = t->tm_sec / 2 + t->tm_min * 32 + t->tm_hour * 2048;
-int write_zip_archive(struct archiver_args *args)
+static int write_zip_archive(struct archiver_args *args)
int err;
@@ -278,3 +278,14 @@ int write_zip_archive(struct archiver_args *args)
return err;
+static struct archiver zip_archiver = {
+ "zip",
+ write_zip_archive,
+void init_zip_archiver(void)
+ register_archiver(&zip_archiver);