diff options
author | René Scharfe <l.s.r@web.de> | 2022-10-30 14:51:14 +0300 |
---|---|---|
committer | Taylor Blau <me@ttaylorr.com> | 2022-10-30 21:04:40 +0300 |
commit | 0e90673957f12adc1a84b13d3dfff02151e4a7a8 (patch) | |
tree | 737050f737be02089d750d4a291cc65421afc89b /add-interactive.c | |
parent | 4120294cbf8e434c1de408434842d570eba0e25d (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 'add-interactive.c')
-rw-r--r-- | add-interactive.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/add-interactive.c b/add-interactive.c index f071b2a1b4..ecc5ae1b24 100644 --- a/add-interactive.c +++ b/add-interactive.c @@ -997,18 +997,17 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps, count = list_and_choose(s, files, opts); opts->flags = 0; if (count > 0) { - struct strvec args = STRVEC_INIT; + struct child_process cmd = CHILD_PROCESS_INIT; - strvec_pushl(&args, "git", "diff", "-p", "--cached", + strvec_pushl(&cmd.args, "git", "diff", "-p", "--cached", oid_to_hex(!is_initial ? &oid : s->r->hash_algo->empty_tree), "--", NULL); for (i = 0; i < files->items.nr; i++) if (files->selected[i]) - strvec_push(&args, + strvec_push(&cmd.args, files->items.items[i].string); - res = run_command_v_opt(args.v, 0); - strvec_clear(&args); + res = run_command(&cmd); } putchar('\n'); |