summaryrefslogtreecommitdiff
path: root/archive-tar.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2011-06-21 21:23:33 -0400
committerJunio C Hamano <gitster@pobox.com>2011-06-22 11:12:35 -0700
commit13e0f88d4aba326da9217c225d6ab5e642eb611d (patch)
treeaf7e13e62c420620946b152ea383f680d6105a94 /archive-tar.c
parent40e7629194c79e72009b5b8e98cce65921b0faf2 (diff)
downloadgit-13e0f88d4aba326da9217c225d6ab5e642eb611d.tar.gz
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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'archive-tar.c')
-rw-r--r--archive-tar.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/archive-tar.c b/archive-tar.c
index 1ab1a2caf5..930375bf21 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -234,12 +234,10 @@ static int git_tar_config(const char *var, const char *value, void *cb)
return 0;
}
-int write_tar_archive(struct archiver_args *args)
+static int write_tar_archive(struct archiver_args *args)
{
int err = 0;
- git_config(git_tar_config, NULL);
-
if (args->commit_sha1)
err = write_global_extended_header(args);
if (!err)
@@ -248,3 +246,15 @@ int write_tar_archive(struct archiver_args *args)
write_trailer();
return err;
}
+
+static struct archiver tar_archiver = {
+ "tar",
+ write_tar_archive,
+ 0
+};
+
+void init_tar_archiver(void)
+{
+ register_archiver(&tar_archiver);
+ git_config(git_tar_config, NULL);
+}