summaryrefslogtreecommitdiff
path: root/builtin/archive.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/archive.c')
-rw-r--r--builtin/archive.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/builtin/archive.c b/builtin/archive.c
index 90761fdfee..13ea7308c8 100644
--- a/builtin/archive.c
+++ b/builtin/archive.c
@@ -8,8 +8,6 @@
#include "transport.h"
#include "parse-options.h"
#include "pkt-line.h"
-#include "repository.h"
-#include "sideband.h"
static void create_output_file(const char *output_file)
{
@@ -32,9 +30,7 @@ static int run_remote_archiver(int argc, const char **argv,
struct packet_reader reader;
_remote = remote_get(remote);
- if (!_remote->url[0])
- die(_("git archive: Remote with no URL"));
- transport = transport_get(_remote, _remote->url[0]);
+ transport = transport_get(_remote, _remote->url.v[0]);
transport_connect(transport, "git-upload-archive", exec, fd);
/*
@@ -79,7 +75,10 @@ static int run_remote_archiver(int argc, const char **argv,
PARSE_OPT_KEEP_UNKNOWN_OPT | \
PARSE_OPT_NO_INTERNAL_HELP )
-int cmd_archive(int argc, const char **argv, const char *prefix)
+int cmd_archive(int argc,
+ const char **argv,
+ const char *prefix,
+ struct repository *repo)
{
const char *exec = "git-upload-archive";
char *output = NULL;
@@ -93,6 +92,7 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
N_("path to the remote git-upload-archive command")),
OPT_END()
};
+ int ret;
argc = parse_options(argc, argv, prefix, local_opts, NULL,
PARSE_OPT_KEEP_ALL);
@@ -102,11 +102,16 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
if (output)
create_output_file(output);
- if (remote)
- return run_remote_archiver(argc, argv, remote, exec, output);
+ if (remote) {
+ ret = run_remote_archiver(argc, argv, remote, exec, output);
+ goto out;
+ }
setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
- UNLEAK(output);
- return write_archive(argc, argv, prefix, the_repository, output, 0);
+ ret = write_archive(argc, argv, prefix, repo, output, 0);
+
+out:
+ free(output);
+ return ret;
}