Browse Source

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>
maint
René Scharfe 9 years ago committed by Junio C Hamano
parent
commit
542aa25d97
  1. 3
      builtin/submodule--helper.c
  2. 6
      builtin/worktree.c

3
builtin/submodule--helper.c

@ -444,8 +444,7 @@ static int module_name(int argc, const char **argv, const char *prefix) @@ -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,
const char *depth, const char *reference, int quiet)
{
struct child_process cp;
child_process_init(&cp);
struct child_process cp = CHILD_PROCESS_INIT;

argv_array_push(&cp.args, "clone");
argv_array_push(&cp.args, "--no-checkout");

6
builtin/worktree.c

@ -194,7 +194,7 @@ static int add_worktree(const char *path, const char *refname, @@ -194,7 +194,7 @@ static int add_worktree(const char *path, const char *refname,
struct strbuf sb = STRBUF_INIT;
const char *name;
struct stat st;
struct child_process cp;
struct child_process cp = CHILD_PROCESS_INIT;
struct argv_array child_env = ARGV_ARRAY_INIT;
int counter = 0, len, ret;
struct strbuf symref = STRBUF_INIT;
@ -273,7 +273,6 @@ static int add_worktree(const char *path, const char *refname, @@ -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_WORK_TREE_ENVIRONMENT, path);
memset(&cp, 0, sizeof(cp));
cp.git_cmd = 1;

if (commit)
@ -365,8 +364,7 @@ static int add(int ac, const char **av, const char *prefix) @@ -365,8 +364,7 @@ static int add(int ac, const char **av, const char *prefix)
}

if (opts.new_branch) {
struct child_process cp;
memset(&cp, 0, sizeof(cp));
struct child_process cp = CHILD_PROCESS_INIT;
cp.git_cmd = 1;
argv_array_push(&cp.args, "branch");
if (opts.force_new_branch)

Loading…
Cancel
Save