summaryrefslogtreecommitdiff
path: root/archive.c
diff options
context:
space:
mode:
Diffstat (limited to 'archive.c')
-rw-r--r--archive.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/archive.c b/archive.c
index b8b45bad77..75eb257760 100644
--- a/archive.c
+++ b/archive.c
@@ -155,3 +155,21 @@ int write_archive_entries(struct archiver_args *args,
err = 0;
return err;
}
+
+int write_archive(int argc, const char **argv, const char *prefix,
+ int setup_prefix)
+{
+ const struct archiver *ar = NULL;
+ struct archiver_args args;
+ int tree_idx;
+
+ tree_idx = parse_archive_args(argc, argv, &ar, &args);
+ if (setup_prefix && prefix == NULL)
+ prefix = setup_git_directory();
+
+ argv += tree_idx;
+ parse_treeish_arg(argv, &args, prefix);
+ parse_pathspec_arg(argv + 1, &args);
+
+ return ar->write_archive(&args);
+}