Skip to content

Commit c7191fa

Browse files
rscharfegitster
authored andcommitted
http: use internal argv_array of struct child_process
Avoid a strangely magic array size (it's slightly too big) and explicit index numbers by building the command line for index-pack using the embedded argv_array of the child_process. Add the flag -o and its argument with argv_array_pushl() to make it obvious that they belong together. The resulting code is shorter and easier to extend. Helped-by: Eric Sunshine <[email protected]> Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 936d1b9 commit c7191fa

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

http.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,7 +2025,6 @@ int finish_http_pack_request(struct http_pack_request *preq)
20252025
char *tmp_idx;
20262026
size_t len;
20272027
struct child_process ip = CHILD_PROCESS_INIT;
2028-
const char *ip_argv[8];
20292028

20302029
close_pack_index(p);
20312030

@@ -2041,13 +2040,9 @@ int finish_http_pack_request(struct http_pack_request *preq)
20412040
die("BUG: pack tmpfile does not end in .pack.temp?");
20422041
tmp_idx = xstrfmt("%.*s.idx.temp", (int)len, preq->tmpfile);
20432042

2044-
ip_argv[0] = "index-pack";
2045-
ip_argv[1] = "-o";
2046-
ip_argv[2] = tmp_idx;
2047-
ip_argv[3] = preq->tmpfile;
2048-
ip_argv[4] = NULL;
2049-
2050-
ip.argv = ip_argv;
2043+
argv_array_push(&ip.args, "index-pack");
2044+
argv_array_pushl(&ip.args, "-o", tmp_idx, NULL);
2045+
argv_array_push(&ip.args, preq->tmpfile);
20512046
ip.git_cmd = 1;
20522047
ip.no_stdin = 1;
20532048
ip.no_stdout = 1;

0 commit comments

Comments
 (0)