summaryrefslogtreecommitdiff
path: root/archive.c
diff options
context:
space:
mode:
authorRene Scharfe <rene.scharfe@lsrfire.ath.cx>2008-07-25 12:41:21 +0200
committerJunio C Hamano <gitster@pobox.com>2008-07-25 17:16:12 -0700
commit6e94e6835f397cd2602ca1eb12002e51aa6b0500 (patch)
tree243d614ba5341500b1b5ea3994e106cdb85f1e21 /archive.c
parentd3296e37b61fdd80a8b785270b1d11db34dab2f5 (diff)
downloadgit-6e94e6835f397cd2602ca1eb12002e51aa6b0500.tar.gz
archive: add write_archive()
Both archive and upload-archive have to parse command line arguments and then call the archiver specific write function. Move the duplicate code to a new function, write_archive(). Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
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);
+}