summaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/transport.c b/transport.c
index e735633..662421b 100644
--- a/transport.c
+++ b/transport.c
@@ -192,7 +192,9 @@ static void set_upstreams(struct transport *transport, struct ref *refs,
static const char *rsync_url(const char *url)
{
- return !starts_with(url, "rsync://") ? skip_prefix(url, "rsync:") : url;
+ if (!starts_with(url, "rsync://"))
+ skip_prefix(url, "rsync:", &url);
+ return url;
}
static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)
@@ -261,32 +263,20 @@ static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)
static int fetch_objs_via_rsync(struct transport *transport,
int nr_objs, struct ref **to_fetch)
{
- struct strbuf buf = STRBUF_INIT;
struct child_process rsync;
- const char *args[8];
- int result;
-
- strbuf_addstr(&buf, rsync_url(transport->url));
- strbuf_addstr(&buf, "/objects/");
memset(&rsync, 0, sizeof(rsync));
- rsync.argv = args;
rsync.stdout_to_stderr = 1;
- args[0] = "rsync";
- args[1] = (transport->verbose > 1) ? "-rv" : "-r";
- args[2] = "--ignore-existing";
- args[3] = "--exclude";
- args[4] = "info";
- args[5] = buf.buf;
- args[6] = get_object_directory();
- args[7] = NULL;
+ argv_array_push(&rsync.args, "rsync");
+ argv_array_push(&rsync.args, (transport->verbose > 1) ? "-rv" : "-r");
+ argv_array_push(&rsync.args, "--ignore-existing");
+ argv_array_push(&rsync.args, "--exclude");
+ argv_array_push(&rsync.args, "info");
+ argv_array_pushf(&rsync.args, "%s/objects/", rsync_url(transport->url));
+ argv_array_push(&rsync.args, get_object_directory());
/* NEEDSWORK: handle one level of alternates */
- result = run_command(&rsync);
-
- strbuf_release(&buf);
-
- return result;
+ return run_command(&rsync);
}
static int write_one_ref(const char *name, const unsigned char *sha1,
@@ -1186,10 +1176,8 @@ int transport_push(struct transport *transport,
if ((flags & (TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND |
TRANSPORT_RECURSE_SUBMODULES_CHECK)) && !is_bare_repository()) {
struct ref *ref = remote_refs;
- struct string_list needs_pushing;
+ struct string_list needs_pushing = STRING_LIST_INIT_DUP;
- memset(&needs_pushing, 0, sizeof(struct string_list));
- needs_pushing.strdup_strings = 1;
for (; ref; ref = ref->next)
if (!is_null_sha1(ref->new_sha1) &&
find_unpushed_submodules(ref->new_sha1,