Merge branch 'rs/child-process-init'

A small code clean-up.

* rs/child-process-init:
  use CHILD_PROCESS_INIT to initialize automatic variables
This commit is contained in:
Junio C Hamano 2016-08-12 09:47:36 -07:00
commit 18f3ce8841
2 changed files with 3 additions and 6 deletions

View File

@ -444,8 +444,7 @@ static int module_name(int argc, const char **argv, const char *prefix)
static int clone_submodule(const char *path, const char *gitdir, const char *url, static int clone_submodule(const char *path, const char *gitdir, const char *url,
const char *depth, const char *reference, int quiet) const char *depth, const char *reference, int quiet)
{ {
struct child_process cp; struct child_process cp = CHILD_PROCESS_INIT;
child_process_init(&cp);
argv_array_push(&cp.args, "clone"); argv_array_push(&cp.args, "clone");
argv_array_push(&cp.args, "--no-checkout"); argv_array_push(&cp.args, "--no-checkout");

View File

@ -194,7 +194,7 @@ static int add_worktree(const char *path, const char *refname,
struct strbuf sb = STRBUF_INIT; struct strbuf sb = STRBUF_INIT;
const char *name; const char *name;
struct stat st; struct stat st;
struct child_process cp; struct child_process cp = CHILD_PROCESS_INIT;
struct argv_array child_env = ARGV_ARRAY_INIT; struct argv_array child_env = ARGV_ARRAY_INIT;
int counter = 0, len, ret; int counter = 0, len, ret;
struct strbuf symref = STRBUF_INIT; struct strbuf symref = STRBUF_INIT;
@ -273,7 +273,6 @@ static int add_worktree(const char *path, const char *refname,
argv_array_pushf(&child_env, "%s=%s", GIT_DIR_ENVIRONMENT, sb_git.buf); argv_array_pushf(&child_env, "%s=%s", GIT_DIR_ENVIRONMENT, sb_git.buf);
argv_array_pushf(&child_env, "%s=%s", GIT_WORK_TREE_ENVIRONMENT, path); argv_array_pushf(&child_env, "%s=%s", GIT_WORK_TREE_ENVIRONMENT, path);
memset(&cp, 0, sizeof(cp));
cp.git_cmd = 1; cp.git_cmd = 1;
if (commit) if (commit)
@ -365,8 +364,7 @@ static int add(int ac, const char **av, const char *prefix)
} }
if (opts.new_branch) { if (opts.new_branch) {
struct child_process cp; struct child_process cp = CHILD_PROCESS_INIT;
memset(&cp, 0, sizeof(cp));
cp.git_cmd = 1; cp.git_cmd = 1;
argv_array_push(&cp.args, "branch"); argv_array_push(&cp.args, "branch");
if (opts.force_new_branch) if (opts.force_new_branch)