use CHILD_PROCESS_INIT to initialize automatic variables

Initialize struct child_process variables already when they're defined. That's shorter and saves a function call. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Aug 5, 2016 at 22:38 UTC 542aa25d9748c381a27074fb08614d4cb4713984
2 files changed +3 -6
builtin/submodule--helper.c
+1 -2
@@ -444,8 +444,7 @@ static int module_name(int argc, const char **argv, const char *prefix)
444 static int clone_submodule(const char *path, const char *gitdir, const char *url,
445 const char *depth, const char *reference, int quiet)
446 {
447 - struct child_process cp;
448 - child_process_init(&cp);
447 + struct child_process cp = CHILD_PROCESS_INIT;
448
449 argv_array_push(&cp.args, "clone");
450 argv_array_push(&cp.args, "--no-checkout");
builtin/worktree.c
+2 -4
@@ -194,7 +194,7 @@ static int add_worktree(const char *path, const char *refname,
194 struct strbuf sb = STRBUF_INIT;
195 const char *name;
196 struct stat st;
197 - struct child_process cp;
197 + struct child_process cp = CHILD_PROCESS_INIT;
198 struct argv_array child_env = ARGV_ARRAY_INIT;
199 int counter = 0, len, ret;
200 struct strbuf symref = STRBUF_INIT;
@@ -273,7 +273,6 @@ static int add_worktree(const char *path, const char *refname,
273
274 argv_array_pushf(&child_env, "%s=%s", GIT_DIR_ENVIRONMENT, sb_git.buf);
275 argv_array_pushf(&child_env, "%s=%s", GIT_WORK_TREE_ENVIRONMENT, path);
276 - memset(&cp, 0, sizeof(cp));
276 cp.git_cmd = 1;
277
278 if (commit)
@@ -365,8 +364,7 @@ static int add(int ac, const char **av, const char *prefix)
364 }
365
366 if (opts.new_branch) {
368 - struct child_process cp;
369 - memset(&cp, 0, sizeof(cp));
367 + struct child_process cp = CHILD_PROCESS_INIT;
368 cp.git_cmd = 1;
369 argv_array_push(&cp.args, "branch");
370 if (opts.force_new_branch)