mirror of
https://github.com/git/git.git
synced 2026-01-09 01:34:00 +00:00
run-command API users: use strvec_push(), not argv construction
Change a pattern of hardcoding an "argv" array size, populating it and assigning to the "argv" member of "struct child_process" to instead use "strvec_push()" to add data to the "args" member. As noted in the preceding commit this moves us further towards being able to remove the "argv" member in a subsequent commit These callers could have used strvec_pushl(), but moving to strvec_push() makes the diff easier to read, and keeps the arguments aligned as before. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
2b7098936c
commit
7f14609e29
18
daemon.c
18
daemon.c
@@ -326,22 +326,18 @@ static int run_access_hook(struct daemon_service *service, const char *dir,
|
||||
{
|
||||
struct child_process child = CHILD_PROCESS_INIT;
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
const char *argv[8];
|
||||
const char **arg = argv;
|
||||
char *eol;
|
||||
int seen_errors = 0;
|
||||
|
||||
*arg++ = access_hook;
|
||||
*arg++ = service->name;
|
||||
*arg++ = path;
|
||||
*arg++ = hi->hostname.buf;
|
||||
*arg++ = get_canon_hostname(hi);
|
||||
*arg++ = get_ip_address(hi);
|
||||
*arg++ = hi->tcp_port.buf;
|
||||
*arg = NULL;
|
||||
strvec_push(&child.args, access_hook);
|
||||
strvec_push(&child.args, service->name);
|
||||
strvec_push(&child.args, path);
|
||||
strvec_push(&child.args, hi->hostname.buf);
|
||||
strvec_push(&child.args, get_canon_hostname(hi));
|
||||
strvec_push(&child.args, get_ip_address(hi));
|
||||
strvec_push(&child.args, hi->tcp_port.buf);
|
||||
|
||||
child.use_shell = 1;
|
||||
child.argv = argv;
|
||||
child.no_stdin = 1;
|
||||
child.no_stderr = 1;
|
||||
child.out = -1;
|
||||
|
||||
Reference in New Issue
Block a user