Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
remote-curl.c: convert fetch_git() to use argv_array
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Sun, 12 Jun 2016 10:53:43 +0000
(17:53 +0700)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 13 Jun 2016 21:38:16 +0000
(14:38 -0700)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote-curl.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
7c0da37
)
diff --git
a/remote-curl.c
b/remote-curl.c
index c7048575fbdca1bd8dc57c114d0cfdc031e63039..fd030c13c842919c1d23fe7d3c906c9623a4a9a4 100644
(file)
--- a/
remote-curl.c
+++ b/
remote-curl.c
@@
-725,38
+725,28
@@
static int fetch_git(struct discovery *heads,
{
struct rpc_state rpc;
struct strbuf preamble = STRBUF_INIT;
{
struct rpc_state rpc;
struct strbuf preamble = STRBUF_INIT;
- char *depth_arg = NULL;
- int argc = 0, i, err;
- const char *argv[17];
-
- argv[argc++] = "fetch-pack";
- argv[argc++] = "--stateless-rpc";
- argv[argc++] = "--stdin";
- argv[argc++] = "--lock-pack";
+ int i, err;
+ struct argv_array args = ARGV_ARRAY_INIT;
+
+ argv_array_pushl(&args, "fetch-pack", "--stateless-rpc",
+ "--stdin", "--lock-pack", NULL);
if (options.followtags)
if (options.followtags)
- argv
[argc++] = "--include-tag"
;
+ argv
_array_push(&args, "--include-tag")
;
if (options.thin)
if (options.thin)
- argv[argc++] = "--thin";
- if (options.verbosity >= 3) {
- argv[argc++] = "-v";
- argv[argc++] = "-v";
- }
+ argv_array_push(&args, "--thin");
+ if (options.verbosity >= 3)
+ argv_array_pushl(&args, "-v", "-v", NULL);
if (options.check_self_contained_and_connected)
if (options.check_self_contained_and_connected)
- argv
[argc++] = "--check-self-contained-and-connected"
;
+ argv
_array_push(&args, "--check-self-contained-and-connected")
;
if (options.cloning)
if (options.cloning)
- argv
[argc++] = "--cloning"
;
+ argv
_array_push(&args, "--cloning")
;
if (options.update_shallow)
if (options.update_shallow)
- argv
[argc++] = "--update-shallow"
;
+ argv
_array_push(&args, "--update-shallow")
;
if (!options.progress)
if (!options.progress)
- argv[argc++] = "--no-progress";
- if (options.depth) {
- struct strbuf buf = STRBUF_INIT;
- strbuf_addf(&buf, "--depth=%lu", options.depth);
- depth_arg = strbuf_detach(&buf, NULL);
- argv[argc++] = depth_arg;
- }
- argv[argc++] = url.buf;
- argv[argc++] = NULL;
+ argv_array_push(&args, "--no-progress");
+ if (options.depth)
+ argv_array_pushf(&args, "--depth=%lu", options.depth);
+ argv_array_push(&args, url.buf);
for (i = 0; i < nr_heads; i++) {
struct ref *ref = to_fetch[i];
for (i = 0; i < nr_heads; i++) {
struct ref *ref = to_fetch[i];
@@
-769,7
+759,7
@@
static int fetch_git(struct discovery *heads,
memset(&rpc, 0, sizeof(rpc));
rpc.service_name = "git-upload-pack",
memset(&rpc, 0, sizeof(rpc));
rpc.service_name = "git-upload-pack",
- rpc.argv = argv;
+ rpc.argv = arg
s.arg
v;
rpc.stdin_preamble = &preamble;
rpc.gzip_request = 1;
rpc.stdin_preamble = &preamble;
rpc.gzip_request = 1;
@@
-778,7
+768,7
@@
static int fetch_git(struct discovery *heads,
write_or_die(1, rpc.result.buf, rpc.result.len);
strbuf_release(&rpc.result);
strbuf_release(&preamble);
write_or_die(1, rpc.result.buf, rpc.result.len);
strbuf_release(&rpc.result);
strbuf_release(&preamble);
-
free(depth_arg
);
+
argv_array_clear(&args
);
return err;
}
return err;
}