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

Re: [PATCH v2 2/2] builtin/am: allow disabling conflict advice

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 11, 2024, 17:49 UTC
Message-ID
<xmqq1q8gsloz.fsf@gitster.g>
In-Reply-To
<xmqq5xxsu1z5.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 9 quoted lines
>> I think you need to append "\n" to the message strings here (and
>> below) to match the behavior of printf_ln().
>
> Good eyes.  You'll get the final "\n" but the line breaks inside the
> paragraph you give to advise*() functions are your responsibility.
> Even though advice.c:vadvise() handles multi-line message better
> (unlike usage.c:vreportf() that is used for error() and die()) by
> giving a line header for each line of the message, we do not wrap
> lines at runtime.
Perhaps something like this.

The overly long lines are getting a bit annoying but I do not offhand think of a good way to shorten them.

Also, having to assemble the message in a buffer and emit them all once with ("%s" % sb.buf) is a highly annoying pattern. Perhaps given enough examples, somebody will come up with a simpler API to do the same thing, but that is not in the scope of this series.

 builtin/am.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff --git i/builtin/am.c w/builtin/am.c
index 0e97b827e4..227036d732 100644
--- i/builtin/am.c
+++ w/builtin/am.c
@@ -1155,14 +1155,13 @@ static void NORETURN die_user_resolve(const struct am_state *state)
 		const char *cmdline = state->interactive ? "git am -i" : "git am";
 		struct strbuf sb = STRBUF_INIT;
 
-		strbuf_addf(&sb, _("When you have resolved this problem, run \"%s --continue\"."), cmdline);
-		strbuf_addf(&sb, _("If you prefer to skip this patch, run \"%s --skip\" instead."), cmdline);
+		strbuf_addf(&sb, _("When you have resolved this problem, run \"%s --continue\".\n"), cmdline);
+		strbuf_addf(&sb, _("If you prefer to skip this patch, run \"%s --skip\" instead.\n"), cmdline);
 
 		if (advice_enabled(ADVICE_AM_WORK_DIR) &&
 		    is_empty_or_missing_file(am_path(state, "patch")) &&
 		    !repo_index_has_changes(the_repository, NULL, NULL))
-			strbuf_addf(&sb, _("To record the empty patch as an empty commit, run \"%s --allow-empty\"."), cmdline);
-
+			strbuf_addf(&sb, _("To record the empty patch as an empty commit, run \"%s --allow-empty\".\n"), cmdline);
 		strbuf_addf(&sb, _("To restore the original branch and stop patching, run \"%s --abort\"."), cmdline);
 
 		advise_if_enabled(ADVICE_MERGE_CONFLICT, "%s", sb.buf);
Previous: Junio C HamanoNext: Philippe Blain
Message 22 of 32 in “sequencer: allow disabling conflict advice”
  1. sequencer: allow disabling conflict advicePhilippe Blain via GitGitGadget, Mar 2, 2024
  2. Philippe BlainMar 2, 2024
  3. Junio C HamanoMar 3, 2024
  4. Philippe BlainMar 9, 2024
  5. Philippe BlainMar 9, 2024
  6. Junio C HamanoMar 9, 2024
  7. Junio C HamanoMar 9, 2024
  8. Phillip WoodMar 4, 2024
  9. Phillip WoodMar 4, 2024
  10. Junio C HamanoMar 4, 2024
  11. Philippe BlainMar 9, 2024
  12. Phillip WoodMar 9, 2024
  13. Junio C HamanoMar 9, 2024
  14. Philippe BlainMar 9, 2024
  15. 0/2 Allow disabling advice shown after merge conflictsPhilippe Blain via GitGitGadget, Mar 10, 2024
  16. 1/2 sequencer: allow disabling conflict advicePhilippe Blain via GitGitGadget, Mar 10, 2024
  17. Kristoffer HaugsbakkMar 11, 2024
  18. Philippe BlainMar 16, 2024
  19. 2/2 builtin/am: allow disabling conflict advicePhilippe Blain via GitGitGadget, Mar 10, 2024
  20. phillip.wood123@gmail.comMar 11, 2024
  21. Junio C HamanoMar 11, 2024
  22. Junio C HamanoMar 11, 2024
  23. Philippe BlainMar 16, 2024
  24. Philippe BlainMar 16, 2024
  25. Rubén JustoMar 11, 2024
  26. Philippe BlainMar 16, 2024
  27. 0/2 Allow disabling advice shown after merge conflictsPhilippe Blain via GitGitGadget, Mar 16, 2024
  28. 1/2 sequencer: allow disabling conflict advicePhilippe Blain via GitGitGadget, Mar 16, 2024
  29. 2/2 builtin/am: allow disabling conflict advicePhilippe Blain via GitGitGadget, Mar 16, 2024
  30. Junio C HamanoMar 18, 2024
  31. Phillip WoodMar 25, 2024
  32. Junio C HamanoMar 25, 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.