upload-archive: use regular "struct child_process" pattern

This pattern added [1] in seems to have been intentional, but since [2] and [3] we've wanted do initialization of what's now the "struct strvec" "args" and "env_array" members. Let's not trample on that initialization here. 1. 1bc01efed17 (upload-archive: use start_command instead of fork, 2011-11-19) 2. c460c0ecdca (run-command: store an optional argv_array, 2014-05-15) 3. 9a583dc39e (run-command: add env_array, an optional argv_array for env, 2014-10-19) Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Nov 25, 2021 at 23:52 UTC c8a4cd55d915a51e666863e576bb1cc2adbecabe
1 file changed +3 -2
builtin/upload-archive.c
+3 -2
@@ -77,7 +77,7 @@ static ssize_t process_input(int child_fd, int band)
77
78 int cmd_upload_archive(int argc, const char **argv, const char *prefix)
79 {
80 - struct child_process writer = { argv };
80 + struct child_process writer = CHILD_PROCESS_INIT;
81
82 if (argc == 2 && !strcmp(argv[1], "-h"))
83 usage(upload_archive_usage);
@@ -89,9 +89,10 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)
89 * multiplexed out to our fd#1. If the child dies, we tell the other
90 * end over channel #3.
91 */
92 - argv[0] = "upload-archive--writer";
92 writer.out = writer.err = -1;
93 writer.git_cmd = 1;
94 + strvec_push(&writer.args, "upload-archive--writer");
95 + strvec_pushv(&writer.args, argv + 1);
96 if (start_command(&writer)) {
97 int err = errno;
98 packet_write_fmt(1, "NACK unable to spawn subprocess\n");