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:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2021-11-26 01:52:20 +0300
committerJunio C Hamano <gitster@pobox.com>2021-11-26 09:15:07 +0300
commit2b7098936c9e91d527aa53b8d4af0b25d7e912b4 (patch)
treed0042309f280e1246533b9bd0bcc70d5ff6ebbbc /editor.c
parent87ee87dd6bb633cd5171e244fb69cd4b66d294aa (diff)
run-command API users: use strvec_pushl(), not argv construction
Change a pattern of hardcoding an "argv" array size, populating it and assigning to the "argv" member of "struct child_process" to instead use "strvec_pushl()" to add data to the "args" member. This implements the same behavior as before in fewer lines of code, and moves us further towards being able to remove the "argv" member in a subsequent commit. Since we've entirely removed the "argv" variable(s) we can be sure that no potential logic errors of the type discussed in a preceding commit are being introduced here, i.e. ones where the local "argv" was being modified after the assignment to "struct child_process"'s "argv". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'editor.c')
-rw-r--r--editor.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/editor.c b/editor.c
index fdd3eeafa9..d92a8d9ab5 100644
--- a/editor.c
+++ b/editor.c
@@ -55,7 +55,6 @@ static int launch_specified_editor(const char *editor, const char *path,
if (strcmp(editor, ":")) {
struct strbuf realpath = STRBUF_INIT;
- const char *args[] = { editor, NULL, NULL };
struct child_process p = CHILD_PROCESS_INIT;
int ret, sig;
int print_waiting_for_editor = advice_enabled(ADVICE_WAITING_FOR_EDITOR) && isatty(2);
@@ -77,9 +76,8 @@ static int launch_specified_editor(const char *editor, const char *path,
}
strbuf_realpath(&realpath, path, 1);
- args[1] = realpath.buf;
- p.argv = args;
+ strvec_pushl(&p.args, editor, realpath.buf, NULL);
p.env = env;
p.use_shell = 1;
p.trace2_child_class = "editor";