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>
This commit is contained in:
Rene Scharfe
2008-07-25 12:41:21 +02:00
committed by Junio C Hamano
parent d3296e37b6
commit 6e94e6835f
4 changed files with 21 additions and 21 deletions

View File

@ -232,9 +232,6 @@ static const char *extract_remote_arg(int *ac, const char **av)
int cmd_archive(int argc, const char **argv, const char *prefix)
{
const struct archiver *ar = NULL;
struct archiver_args args;
int tree_idx;
const char *remote = NULL;
remote = extract_remote_arg(&argc, argv);
@ -243,13 +240,5 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
tree_idx = parse_archive_args(argc, argv, &ar, &args);
if (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);
return write_archive(argc, argv, prefix, 1);
}