git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 1/2] launch_editor: waiting for editor message

From
Rubén Justo <rjusto@gmail.com>
Date
Apr 12, 2024, 17:15 UTC
Message-ID
<83b34572-498b-438c-8437-dfbb837e60ba@gmail.com>
In-Reply-To
<ccbd77a1-d334-4d8f-8de0-b542c79330fd@gmail.com>

We have a hint shown when we are waiting for user's editor since abfb04d0c7 (launch_editor(): indicate that Git waits for user input, 2017-12-07).

After showing the hint, we call start_command() which can return with an error. Then we'll show "unable to start editor...", after having said "Waiting for your editor...", which may be confusing.

Move the code to show the hint below the start_command().
Signed-off-by: Rubén Justo <rjusto@gmail.com>
---
 editor.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/editor.c b/editor.c
index b67b802ddf..1da3a26f5d 100644
--- a/editor.c
+++ b/editor.c
@@ -64,9 +64,21 @@ static int launch_specified_editor(const char *editor, const char *path,
 	if (strcmp(editor, ":")) {
 		struct strbuf realpath = STRBUF_INIT;
 		struct child_process p = CHILD_PROCESS_INIT;
-		int ret, sig;
-		int print_waiting_for_editor = advice_enabled(ADVICE_WAITING_FOR_EDITOR) && isatty(2);
+		int ret, sig, print_waiting_for_editor;
 
+		strbuf_realpath(&realpath, path, 1);
+
+		strvec_pushl(&p.args, editor, realpath.buf, NULL);
+		if (env)
+			strvec_pushv(&p.env, (const char **)env);
+		p.use_shell = 1;
+		p.trace2_child_class = "editor";
+		if (start_command(&p) < 0) {
+			strbuf_release(&realpath);
+			return error("unable to start editor '%s'", editor);
+		}
+
+		print_waiting_for_editor = advice_enabled(ADVICE_WAITING_FOR_EDITOR) && isatty(2);
 		if (print_waiting_for_editor) {
 			/*
 			 * A dumb terminal cannot erase the line later on. Add a
@@ -83,18 +95,6 @@ static int launch_specified_editor(const char *editor, const char *path,
 			fflush(stderr);
 		}
 
-		strbuf_realpath(&realpath, path, 1);
-
-		strvec_pushl(&p.args, editor, realpath.buf, NULL);
-		if (env)
-			strvec_pushv(&p.env, (const char **)env);
-		p.use_shell = 1;
-		p.trace2_child_class = "editor";
-		if (start_command(&p) < 0) {
-			strbuf_release(&realpath);
-			return error("unable to start editor '%s'", editor);
-		}
-
 		sigchain_push(SIGINT, SIG_IGN);
 		sigchain_push(SIGQUIT, SIG_IGN);
 		ret = finish_command(&p);
-- 
2.44.0.771.gbd07cf668b
Previous: Rubén JustoNext: rsbecker@nexbridge.com
Message 13 of 26 in “launch_editor: waiting message on error”
  1. launch_editor: waiting message on errorRubén Justo, Apr 8, 2024
  2. launch_editor: waiting message on errorRubén Justo, Apr 8, 2024
  3. launch_editor: waiting message on errorRubén Justo, Apr 8, 2024
  4. Junio C HamanoApr 9, 2024
  5. Rubén JustoApr 9, 2024
  6. Junio C HamanoApr 10, 2024
  7. Rubén JustoApr 11, 2024
  8. Junio C HamanoApr 12, 2024
  9. Rubén JustoApr 12, 2024
  10. Junio C HamanoApr 12, 2024
  11. Rubén JustoApr 12, 2024
  12. 0/2 launch_editor: waiting messageRubén Justo, Apr 12, 2024
  13. 1/2 launch_editor: waiting for editor messageRubén Justo, Apr 12, 2024
  14. rsbecker@nexbridge.comApr 12, 2024
  15. Rubén JustoApr 12, 2024
  16. rsbecker@nexbridge.comApr 12, 2024
  17. Phillip WoodApr 13, 2024
  18. 2/2 launch_editor: waiting message on errorRubén Justo, Apr 12, 2024
  19. Phillip WoodApr 13, 2024
  20. Rubén JustoApr 14, 2024
  21. launch_editor: waiting message on errorRubén Justo, Apr 14, 2024
  22. Phillip WoodApr 15, 2024
  23. Rubén JustoApr 15, 2024
  24. Junio C HamanoApr 15, 2024
  25. Rubén JustoApr 15, 2024
  26. Junio C HamanoApr 15, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.