summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2022-10-30 11:50:27 (GMT)
committerTaylor Blau <me@ttaylorr.com>2022-10-30 18:04:39 (GMT)
commit4120294cbf8e434c1de408434842d570eba0e25d (patch)
tree0def81e9ce1e3fea930a331fde52a8079368ec80 /compat
parent242aa33de0f18bf09dd147401af9b44cf961d532 (diff)
downloadgit-4120294cbf8e434c1de408434842d570eba0e25d.zip
git-4120294cbf8e434c1de408434842d570eba0e25d.tar.gz
git-4120294cbf8e434c1de408434842d570eba0e25d.tar.bz2
use child_process member "args" instead of string array variable
Use run_command() with a struct child_process variable and populate its "args" member directly instead of building a string array and passing it to run_command_v_opt(). This avoids the use of magic index numbers and makes simplifies the possible addition of more arguments in the future. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Taylor Blau <me@ttaylorr.com>
Diffstat (limited to 'compat')
-rw-r--r--compat/mingw.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/compat/mingw.c b/compat/mingw.c
index 901375d..d614f15 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -196,16 +196,19 @@ static int read_yes_no_answer(void)
static int ask_yes_no_if_possible(const char *format, ...)
{
char question[4096];
- const char *retry_hook[] = { NULL, NULL, NULL };
+ const char *retry_hook;
va_list args;
va_start(args, format);
vsnprintf(question, sizeof(question), format, args);
va_end(args);
- if ((retry_hook[0] = mingw_getenv("GIT_ASK_YESNO"))) {
- retry_hook[1] = question;
- return !run_command_v_opt(retry_hook, 0);
+ retry_hook = mingw_getenv("GIT_ASK_YESNO");
+ if (retry_hook) {
+ struct child_process cmd = CHILD_PROCESS_INIT;
+
+ strvec_pushl(&cmd.args, retry_hook, question, NULL);
+ return !run_command(&cmd);
}
if (!isatty(_fileno(stdin)) || !isatty(_fileno(stderr)))