Skip to content

Commit 0956eaa

Browse files
committed
Merge branch 'rs/use-argv-array-in-child-process'
Code cleanup. * rs/use-argv-array-in-child-process: send-pack: use internal argv_array of struct child_process http: use internal argv_array of struct child_process
2 parents a778ba1 + a923e05 commit 0956eaa

File tree

2 files changed

+12
-27
lines changed

2 files changed

+12
-27
lines changed

http.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,6 @@ int finish_http_pack_request(struct http_pack_request *preq)
20302030
char *tmp_idx;
20312031
size_t len;
20322032
struct child_process ip = CHILD_PROCESS_INIT;
2033-
const char *ip_argv[8];
20342033

20352034
close_pack_index(p);
20362035

@@ -2046,13 +2045,9 @@ int finish_http_pack_request(struct http_pack_request *preq)
20462045
die("BUG: pack tmpfile does not end in .pack.temp?");
20472046
tmp_idx = xstrfmt("%.*s.idx.temp", (int)len, preq->tmpfile);
20482047

2049-
ip_argv[0] = "index-pack";
2050-
ip_argv[1] = "-o";
2051-
ip_argv[2] = tmp_idx;
2052-
ip_argv[3] = preq->tmpfile;
2053-
ip_argv[4] = NULL;
2054-
2055-
ip.argv = ip_argv;
2048+
argv_array_push(&ip.args, "index-pack");
2049+
argv_array_pushl(&ip.args, "-o", tmp_idx, NULL);
2050+
argv_array_push(&ip.args, preq->tmpfile);
20562051
ip.git_cmd = 1;
20572052
ip.no_stdin = 1;
20582053
ip.no_stdout = 1;

send-pack.c

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,35 +58,25 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *extra, struc
5858
* the revision parameters to it via its stdin and
5959
* let its stdout go back to the other end.
6060
*/
61-
const char *argv[] = {
62-
"pack-objects",
63-
"--all-progress-implied",
64-
"--revs",
65-
"--stdout",
66-
NULL,
67-
NULL,
68-
NULL,
69-
NULL,
70-
NULL,
71-
NULL,
72-
};
7361
struct child_process po = CHILD_PROCESS_INIT;
7462
FILE *po_in;
7563
int i;
7664
int rc;
7765

78-
i = 4;
66+
argv_array_push(&po.args, "pack-objects");
67+
argv_array_push(&po.args, "--all-progress-implied");
68+
argv_array_push(&po.args, "--revs");
69+
argv_array_push(&po.args, "--stdout");
7970
if (args->use_thin_pack)
80-
argv[i++] = "--thin";
71+
argv_array_push(&po.args, "--thin");
8172
if (args->use_ofs_delta)
82-
argv[i++] = "--delta-base-offset";
73+
argv_array_push(&po.args, "--delta-base-offset");
8374
if (args->quiet || !args->progress)
84-
argv[i++] = "-q";
75+
argv_array_push(&po.args, "-q");
8576
if (args->progress)
86-
argv[i++] = "--progress";
77+
argv_array_push(&po.args, "--progress");
8778
if (is_repository_shallow())
88-
argv[i++] = "--shallow";
89-
po.argv = argv;
79+
argv_array_push(&po.args, "--shallow");
9080
po.in = -1;
9181
po.out = args->stateless_rpc ? -1 : fd;
9282
po.git_cmd = 1;

0 commit comments

Comments
 (0)