launch_editor: refactor to use start/finish_command

The launch_editor function uses the convenient run_command_* interface. Let's use the more flexible start_command and finish_command functions, which will let us manipulate the parent state while we're waiting for the child to finish. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Nov 30, 2012 at 17:41 UTC f42ca31d8d209a43342ea345a52fc0bd43d71cc8
1 file changed +9 -1
editor.c
+9 -1
@@ -37,8 +37,16 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
37
38 if (strcmp(editor, ":")) {
39 const char *args[] = { editor, path, NULL };
40 + struct child_process p;
41
41 - if (run_command_v_opt_cd_env(args, RUN_USING_SHELL, NULL, env))
42 + memset(&p, 0, sizeof(p));
43 + p.argv = args;
44 + p.env = env;
45 + p.use_shell = 1;
46 + if (start_command(&p) < 0)
47 + return error("unable to start editor '%s'", editor);
48 +
49 + if (finish_command(&p))
50 return error("There was a problem with the editor '%s'.",
51 editor);
52 }