Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-10-18 05:40:50 +0300
committerJunio C Hamano <gitster@pobox.com>2019-10-18 05:40:50 +0300
commit90e0d167c68f158309f260496f7f5350faee25ea (patch)
tree28b7b55aed3c881092cae18b8c7b6463e60b53a1
parent3def8ae9a4b18f1cb475e0ac3bc6034aaa29741d (diff)
parent062a309d360d47a7eff0036b7706dc923fe8081e (diff)
Merge branch 'rs/remote-curl-use-argv-array'
Code cleanup. * rs/remote-curl-use-argv-array: remote-curl: use argv_array in parse_push()
-rw-r--r--remote-curl.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/remote-curl.c b/remote-curl.c
index 051f26629d..1612e7f52d 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -1154,7 +1154,7 @@ static void parse_fetch(struct strbuf *buf)
strbuf_reset(buf);
}
-static int push_dav(int nr_spec, char **specs)
+static int push_dav(int nr_spec, const char **specs)
{
struct child_process child = CHILD_PROCESS_INIT;
size_t i;
@@ -1175,7 +1175,7 @@ static int push_dav(int nr_spec, char **specs)
return 0;
}
-static int push_git(struct discovery *heads, int nr_spec, char **specs)
+static int push_git(struct discovery *heads, int nr_spec, const char **specs)
{
struct rpc_state rpc;
int i, err;
@@ -1225,7 +1225,7 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs)
return err;
}
-static int push(int nr_spec, char **specs)
+static int push(int nr_spec, const char **specs)
{
struct discovery *heads = discover_refs("git-receive-pack", 1);
int ret;
@@ -1240,14 +1240,12 @@ static int push(int nr_spec, char **specs)
static void parse_push(struct strbuf *buf)
{
- char **specs = NULL;
- int alloc_spec = 0, nr_spec = 0, i, ret;
+ struct argv_array specs = ARGV_ARRAY_INIT;
+ int ret;
do {
- if (starts_with(buf->buf, "push ")) {
- ALLOC_GROW(specs, nr_spec + 1, alloc_spec);
- specs[nr_spec++] = xstrdup(buf->buf + 5);
- }
+ if (starts_with(buf->buf, "push "))
+ argv_array_push(&specs, buf->buf + 5);
else
die(_("http transport does not support %s"), buf->buf);
@@ -1258,7 +1256,7 @@ static void parse_push(struct strbuf *buf)
break;
} while (1);
- ret = push(nr_spec, specs);
+ ret = push(specs.argc, specs.argv);
printf("\n");
fflush(stdout);
@@ -1266,9 +1264,7 @@ static void parse_push(struct strbuf *buf)
exit(128); /* error already reported */
free_specs:
- for (i = 0; i < nr_spec; i++)
- free(specs[i]);
- free(specs);
+ argv_array_clear(&specs);
}
static int stateless_connect(const char *service_name)