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

[PATCH] launch_editor: waiting message on error

From
Rubén Justo <rjusto@gmail.com>
Date
Apr 8, 2024, 21:07 UTC
Message-ID
<96bef5f9-1286-4938-99ec-6beed13ee68d@gmail.com>
In-Reply-To
<e60c1217-aeb6-48ce-9aa5-7c0b13396e33@gmail.com>

We have the hint we're touching in this commit since abfb04d0c7 (launch_editor(): indicate that Git waits for user input, 2017-12-07).

Adding a new line after the hint when the editor returns error was discussed in the list, but finally it was considered not necessary because a shorter message is used [1].

However, even with a short message, feeding that LF makes out next "error: There was a problem with the..." more clear. For example, the editor could print messages that would be mixed with our error message. So, add that LF.

While we're here, make the error message follow our CodingGuideLines.
 [1] https://public-inbox.org/git/20171127134716.69471-1-lars.schneider@autodesk.com/T/#u
Signed-off-by: Rubén Justo <rjusto@gmail.com>
---
 editor.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/editor.c b/editor.c
index b67b802ddf..0d4c6f94a6 100644
--- a/editor.c
+++ b/editor.c
@@ -104,16 +104,26 @@ static int launch_specified_editor(const char *editor, const char *path,
 		sigchain_pop(SIGQUIT);
 		if (sig == SIGINT || sig == SIGQUIT)
 			raise(sig);
-		if (ret)
-			return error("There was a problem with the editor '%s'.",
-					editor);
 
-		if (print_waiting_for_editor && !is_terminal_dumb())
-			/*
-			 * Erase the entire line to avoid wasting the
-			 * vertical space.
-			 */
-			term_clear_line();
+		if (print_waiting_for_editor && !is_terminal_dumb()) {
+			if (!ret)
+				/*
+			 	 * Erase the entire line to avoid wasting
+			 	 * the vertical space.
+			 	 */
+				term_clear_line();
+			else
+				/*
+				 * We don't want term_clear_line() here
+				 * because the editor could have written
+				 * some useful messages to the user.
+				 */
+				fprintf(stderr, "\n");
+		}
+
+		if (ret) 
+			return error("there was a problem with the editor '%s'",
+					editor);
 	}
 
 	if (!buffer)
-- 
2.43.0
Previous: Rubén JustoNext: Rubén Justo
Message 2 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.