summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2022-10-30 11:51:14 (GMT)
committerTaylor Blau <me@ttaylorr.com>2022-10-30 18:04:40 (GMT)
commit0e90673957f12adc1a84b13d3dfff02151e4a7a8 (patch)
tree737050f737be02089d750d4a291cc65421afc89b /sequencer.c
parent4120294cbf8e434c1de408434842d570eba0e25d (diff)
downloadgit-0e90673957f12adc1a84b13d3dfff02151e4a7a8.zip
git-0e90673957f12adc1a84b13d3dfff02151e4a7a8.tar.gz
git-0e90673957f12adc1a84b13d3dfff02151e4a7a8.tar.bz2
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>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/sequencer.c b/sequencer.c
index 66eedd2..31e24f3 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -3183,18 +3183,15 @@ static int rollback_is_safe(void)
static int reset_merge(const struct object_id *oid)
{
- int ret;
- struct strvec argv = STRVEC_INIT;
+ struct child_process cmd = CHILD_PROCESS_INIT;
- strvec_pushl(&argv, "reset", "--merge", NULL);
+ cmd.git_cmd = 1;
+ strvec_pushl(&cmd.args, "reset", "--merge", NULL);
if (!is_null_oid(oid))
- strvec_push(&argv, oid_to_hex(oid));
+ strvec_push(&cmd.args, oid_to_hex(oid));
- ret = run_command_v_opt(argv.v, RUN_GIT_CMD);
- strvec_clear(&argv);
-
- return ret;
+ return run_command(&cmd);
}
static int rollback_single_pick(struct repository *r)
@@ -4866,14 +4863,14 @@ cleanup_head_ref:
static int continue_single_pick(struct repository *r, struct replay_opts *opts)
{
- struct strvec argv = STRVEC_INIT;
- int ret;
+ struct child_process cmd = CHILD_PROCESS_INIT;
if (!refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") &&
!refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD"))
return error(_("no cherry-pick or revert in progress"));
- strvec_push(&argv, "commit");
+ cmd.git_cmd = 1;
+ strvec_push(&cmd.args, "commit");
/*
* continue_single_pick() handles the case of recovering from a
@@ -4886,11 +4883,9 @@ static int continue_single_pick(struct repository *r, struct replay_opts *opts)
* Include --cleanup=strip as well because we don't want the
* "# Conflicts:" messages.
*/
- strvec_pushl(&argv, "--no-edit", "--cleanup=strip", NULL);
+ strvec_pushl(&cmd.args, "--no-edit", "--cleanup=strip", NULL);
- ret = run_command_v_opt(argv.v, RUN_GIT_CMD);
- strvec_clear(&argv);
- return ret;
+ return run_command(&cmd);
}
static int commit_staged_changes(struct repository *r,