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

[GSoC][PATCH 2/2] sequencer: remove newlines from append_todo_help() messages

From
Alban Gruin <alban.gruin@gmail.com>
Date
May 31, 2018, 11:01 UTC
Message-ID
<20180531110130.18839-3-alban.gruin@gmail.com>
In-Reply-To
<20180531110130.18839-1-alban.gruin@gmail.com>

This removes newlines before and after the messages in append_todo_help(). This is done to avoid confusions from translators.

These newlines are now inserted with `strbuf_add_commented_lines()`. Messages were ended by two newlines characters, but here we only insert one at a time. This is because `strbuf_add_commented_lines()` automatically inserts a newline at the end of the input, and ignore the last from the input.

Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
---
 sequencer.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index 9b291845e..9ab6c28d7 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -4228,7 +4228,7 @@ int append_todo_help(unsigned edit_todo, unsigned keep_empty)
 	struct strbuf buf = STRBUF_INIT;
 	FILE *todo;
 	int ret;
-	const char *msg = _("\nCommands:\n"
+	const char *msg = _("Commands:\n"
 "p, pick <commit> = use commit\n"
 "r, reword <commit> = use commit, but edit the commit message\n"
 "e, edit <commit> = use commit, but stop for amending\n"
@@ -4243,33 +4243,37 @@ int append_todo_help(unsigned edit_todo, unsigned keep_empty)
 ".       message (or the oneline, if no original merge commit was\n"
 ".       specified). Use -c <commit> to reword the commit message.\n"
 "\n"
-"These lines can be re-ordered; they are executed from top to bottom.\n");
+"These lines can be re-ordered; they are executed from top to bottom.");
 
 	todo = fopen_or_warn(rebase_path_todo(), "a");
 	if (!todo)
 		return 1;
 
+	strbuf_add_commented_lines(&buf, "\n", 1);
 	strbuf_add_commented_lines(&buf, msg, strlen(msg));
 
 	if (get_missing_commit_check_level() == CHECK_ERROR)
-		msg = _("\nDo not remove any line. Use 'drop' "
-			 "explicitly to remove a commit.\n");
+		msg = _("Do not remove any line. Use 'drop' "
+			 "explicitly to remove a commit.");
 	else
-		msg = _("\nIf you remove a line here "
-			 "THAT COMMIT WILL BE LOST.\n");
+		msg = _("If you remove a line here "
+			 "THAT COMMIT WILL BE LOST.");
 
+	strbuf_add_commented_lines(&buf, "\n", 1);
 	strbuf_add_commented_lines(&buf, msg, strlen(msg));
 
 	if (edit_todo)
-		msg = _("\nYou are editing the todo file "
+		msg = _("You are editing the todo file "
 			"of an ongoing interactive rebase.\n"
 			"To continue rebase after editing, run:\n"
-			"    git rebase --continue\n\n");
+			"    git rebase --continue");
 	else
-		msg = _("\nHowever, if you remove everything, "
-			"the rebase will be aborted.\n\n");
+		msg = _("However, if you remove everything, "
+			"the rebase will be aborted.");
 
+	strbuf_add_commented_lines(&buf, "\n", 1);
 	strbuf_add_commented_lines(&buf, msg, strlen(msg));
+	strbuf_add_commented_lines(&buf, "\n", 1);
 
 	if (!keep_empty) {
 		msg = _("Note that empty commits are commented out");
-- 
2.16.4
Previous: Alban GruinNext: Phillip Wood
Message 3 of 27 in “rebase -i: rewrite append_todo_help() in C”
  1. Alban GruinMay 31, 2018
  2. [GSoC][PATCH 1/2] rebase--interactive: rewrite append_todo_help() in CAlban Gruin, May 31, 2018
  3. [GSoC][PATCH 2/2] sequencer: remove newlines from append_todo_help() messagesAlban Gruin, May 31, 2018
  4. Phillip WoodMay 31, 2018
  5. Stefan BellerMay 31, 2018
  6. Alban GruinMay 31, 2018
  7. Stefan BellerMay 31, 2018
  8. Phillip WoodJun 1, 2018
  9. Stefan BellerJun 1, 2018
  10. Alban GruinMay 31, 2018
  11. Phillip WoodJun 1, 2018
  12. [GSoC][PATCH v2 0/1] rebase -i: rewrite append_todo_help() in CAlban Gruin, Jun 5, 2018
  13. [GSoC][PATCH v2 1/1] rebase--interactive: rewrite append_todo_help() in CAlban Gruin, Jun 5, 2018
  14. [GSoC][PATCH v3 0/1] rebase -i: rewrite append_todo_help() in CAlban Gruin, Jun 7, 2018
  15. [GSoC][PATCH v3 1/1] rebase--interactive: rewrite append_todo_help() in CAlban Gruin, Jun 7, 2018
  16. [GSoC][PATCH v4 0/2] rebase -i: rewrite append_todo_help() in CAlban Gruin, Jun 26, 2018
  17. [GSoC][PATCH v4 1/2] sequencer: make two functions and an enum from sequencer.c publicAlban Gruin, Jun 26, 2018
  18. Johannes SchindelinJun 26, 2018
  19. Alban GruinJun 27, 2018
  20. [GSoC][PATCH v4 2/2] rebase--interactive: rewrite append_todo_help() in CAlban Gruin, Jun 26, 2018
  21. Johannes SchindelinJun 26, 2018
  22. Johannes SchindelinJun 26, 2018
  23. Alban GruinJun 27, 2018
  24. [GSoC][PATCH v5 0/2] rebase -i: rewrite append_todo_help() in CAlban Gruin, Jun 28, 2018
  25. [GSoC][PATCH v5 1/2] sequencer: make two functions and an enum from sequencer.c publicAlban Gruin, Jun 28, 2018
  26. [GSoC][PATCH v5 2/2] rebase--interactive: rewrite append_todo_help() in CAlban Gruin, Jun 28, 2018
  27. Junio C HamanoJun 28, 2018

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.