use child_process members "args" and "env" directly
Build argument list and environment of child processes by using struct child_process and populating its members "args" and "env" directly instead of maintaining separate strvecs and letting run_command_v_opt() and friends populate these members. This is simpler, shorter and slightly more efficient. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Taylor Blau <me@ttaylorr.com>
This commit is contained in:
committed by
Taylor Blau
parent
4120294cbf
commit
0e90673957
@ -372,22 +372,22 @@ static void reset_hard(const struct object_id *oid)
|
||||
static void restore_state(const struct object_id *head,
|
||||
const struct object_id *stash)
|
||||
{
|
||||
struct strvec args = STRVEC_INIT;
|
||||
struct child_process cmd = CHILD_PROCESS_INIT;
|
||||
|
||||
reset_hard(head);
|
||||
|
||||
if (is_null_oid(stash))
|
||||
goto refresh_cache;
|
||||
|
||||
strvec_pushl(&args, "stash", "apply", "--index", "--quiet", NULL);
|
||||
strvec_push(&args, oid_to_hex(stash));
|
||||
strvec_pushl(&cmd.args, "stash", "apply", "--index", "--quiet", NULL);
|
||||
strvec_push(&cmd.args, oid_to_hex(stash));
|
||||
|
||||
/*
|
||||
* It is OK to ignore error here, for example when there was
|
||||
* nothing to restore.
|
||||
*/
|
||||
run_command_v_opt(args.v, RUN_GIT_CMD);
|
||||
strvec_clear(&args);
|
||||
cmd.git_cmd = 1;
|
||||
run_command(&cmd);
|
||||
|
||||
refresh_cache:
|
||||
if (discard_cache() < 0 || read_cache() < 0)
|
||||
|
||||
Reference in New Issue
Block a user