credential-cache: use child_process.args

As child_process structure has an embedded strvec args for
formulating the command line, let's use it instead of using
an out-of-line argv[] whose length needs to be maintained
correctly.

Also, when spawning a git subcommand, omit it from the command list
and instead use the .git_cmd bit in the child_process structure.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2020-08-26 14:37:39 -07:00
parent 7cff3b67ac
commit c0e190c168

View File

@ -39,13 +39,13 @@ static int send_request(const char *socket, const struct strbuf *out)
static void spawn_daemon(const char *socket) static void spawn_daemon(const char *socket)
{ {
struct child_process daemon = CHILD_PROCESS_INIT; struct child_process daemon = CHILD_PROCESS_INIT;
const char *argv[] = { NULL, NULL, NULL };
char buf[128]; char buf[128];
int r; int r;
argv[0] = "git-credential-cache--daemon"; strvec_pushl(&daemon.args,
argv[1] = socket; "credential-cache--daemon", socket,
daemon.argv = argv; NULL);
daemon.git_cmd = 1;
daemon.no_stdin = 1; daemon.no_stdin = 1;
daemon.out = -1; daemon.out = -1;