Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2022-10-30 14:51:14 +0300
committerTaylor Blau <me@ttaylorr.com>2022-10-30 21:04:40 +0300
commit0e90673957f12adc1a84b13d3dfff02151e4a7a8 (patch)
tree737050f737be02089d750d4a291cc65421afc89b /builtin/add.c
parent4120294cbf8e434c1de408434842d570eba0e25d (diff)
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 'builtin/add.c')
-rw-r--r--builtin/add.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/builtin/add.c b/builtin/add.c
index f84372964c..626c71ec6a 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -240,8 +240,8 @@ static int refresh(int verbose, const struct pathspec *pathspec)
int run_add_interactive(const char *revision, const char *patch_mode,
const struct pathspec *pathspec)
{
- int status, i;
- struct strvec argv = STRVEC_INIT;
+ int i;
+ struct child_process cmd = CHILD_PROCESS_INIT;
int use_builtin_add_i =
git_env_bool("GIT_TEST_ADD_I_USE_BUILTIN", -1);
@@ -272,19 +272,18 @@ int run_add_interactive(const char *revision, const char *patch_mode,
return !!run_add_p(the_repository, mode, revision, pathspec);
}
- strvec_push(&argv, "add--interactive");
+ strvec_push(&cmd.args, "add--interactive");
if (patch_mode)
- strvec_push(&argv, patch_mode);
+ strvec_push(&cmd.args, patch_mode);
if (revision)
- strvec_push(&argv, revision);
- strvec_push(&argv, "--");
+ strvec_push(&cmd.args, revision);
+ strvec_push(&cmd.args, "--");
for (i = 0; i < pathspec->nr; i++)
/* pass original pathspec, to be re-parsed */
- strvec_push(&argv, pathspec->items[i].original);
+ strvec_push(&cmd.args, pathspec->items[i].original);
- status = run_command_v_opt(argv.v, RUN_GIT_CMD);
- strvec_clear(&argv);
- return status;
+ cmd.git_cmd = 1;
+ return run_command(&cmd);
}
int interactive_add(const char **argv, const char *prefix, int patch)