Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
remote-http: use argv-array
author
Junio C Hamano
<gitster@pobox.com>
Tue, 9 Jul 2013 05:16:31 +0000
(22:16 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 9 Jul 2013 19:34:16 +0000
(12:34 -0700)
Instead of using a hand-managed argument array, use argv-array API
to manage dynamically formulated command line.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote-curl.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
531c8dd
)
diff --git
a/remote-curl.c
b/remote-curl.c
index 60eda6308197ad3d0b5957b9ae34e2dc15dfe5cc..5b3ce9eed299e312c132b590ea4926cfb019a271 100644
(file)
--- a/
remote-curl.c
+++ b/
remote-curl.c
@@
-7,6
+7,7
@@
#include "run-command.h"
#include "pkt-line.h"
#include "sideband.h"
#include "run-command.h"
#include "pkt-line.h"
#include "sideband.h"
+#include "argv-array.h"
static struct remote *remote;
static const char *url; /* always ends with a trailing slash */
static struct remote *remote;
static const char *url; /* always ends with a trailing slash */
@@
-787,36
+788,35
@@
static int push_dav(int nr_spec, char **specs)
static int push_git(struct discovery *heads, int nr_spec, char **specs)
{
struct rpc_state rpc;
static int push_git(struct discovery *heads, int nr_spec, char **specs)
{
struct rpc_state rpc;
- const char **argv;
- int argc = 0, i, err;
+ int i, err;
+ struct argv_array args;
+
+ argv_array_init(&args);
+ argv_array_pushl(&args, "send-pack", "--stateless-rpc", "--helper-status",
+ NULL);
- argv = xmalloc((10 + nr_spec) * sizeof(char*));
- argv[argc++] = "send-pack";
- argv[argc++] = "--stateless-rpc";
- argv[argc++] = "--helper-status";
if (options.thin)
if (options.thin)
- argv
[argc++] = "--thin"
;
+ argv
_array_push(&args, "--thin")
;
if (options.dry_run)
if (options.dry_run)
- argv
[argc++] = "--dry-run"
;
+ argv
_array_push(&args, "--dry-run")
;
if (options.verbosity == 0)
if (options.verbosity == 0)
- argv
[argc++] = "--quiet"
;
+ argv
_array_push(&args, "--quiet")
;
else if (options.verbosity > 1)
else if (options.verbosity > 1)
- argv
[argc++] = "--verbose"
;
- argv
[argc++] = options.progress ? "--progress" : "--no-progress"
;
- argv
[argc++] = url
;
+ argv
_array_push(&args, "--verbose")
;
+ argv
_array_push(&args, options.progress ? "--progress" : "--no-progress")
;
+ argv
_array_push(&args, url)
;
for (i = 0; i < nr_spec; i++)
for (i = 0; i < nr_spec; i++)
- argv[argc++] = specs[i];
- argv[argc++] = NULL;
+ argv_array_push(&args, specs[i]);
memset(&rpc, 0, sizeof(rpc));
rpc.service_name = "git-receive-pack",
memset(&rpc, 0, sizeof(rpc));
rpc.service_name = "git-receive-pack",
- rpc.argv = argv;
+ rpc.argv = arg
s.arg
v;
err = rpc_service(&rpc, heads);
if (rpc.result.len)
write_or_die(1, rpc.result.buf, rpc.result.len);
strbuf_release(&rpc.result);
err = rpc_service(&rpc, heads);
if (rpc.result.len)
write_or_die(1, rpc.result.buf, rpc.result.len);
strbuf_release(&rpc.result);
-
free(argv
);
+
argv_array_clear(&args
);
return err;
}
return err;
}