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

Re: [PATCH v3 1/2] sequencer: replace error() with BUG() in update_squash_messages()

From
Junio C Hamano <gitster@pobox.com>
Date
May 30, 2025, 13:35 UTC
Message-ID
<xmqq7c1ygr1k.fsf@gitster.g>
In-Reply-To
<b812f973d18fbef104f2d30f4719fcc58c8578c0.1748569955.git.gitgitgadget@gmail.com>
"Lidong Yan via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 6 quoted lines
> @@ -2067,6 +2067,9 @@ static int update_squash_messages(struct repository *r,
>  	const char *message, *body;
>  	const char *encoding = get_commit_output_encoding();
>  
> +	if (!is_fixup(command))
> +		BUG("unknown command: %d", command);

This is not necessarily unknown. It may be a known one like TODO_PICK but the reason why we are rejecting it is because it is not either FIXUP or SQUASH, so we should say so. BUG() is a message to our developers, so a clear message that tells them that they are not supposed to pass anything but FIXUP/SQUASH is far better than saying "unknown".

Show 13 quoted lines
>  	if (ctx->current_fixup_count > 0) {
>  		struct strbuf header = STRBUF_INIT;
>  		char *eol;
> @@ -2134,8 +2137,7 @@ static int update_squash_messages(struct repository *r,
>  		strbuf_addstr(&buf, "\n\n");
>  		strbuf_add_commented_lines(&buf, body, strlen(body),
>  					   comment_line_str);
> -	} else
> -		return error(_("unknown command: %d"), command);
> +	}
>  	repo_unuse_commit_buffer(r, commit, message);
>  
>  	if (!res)
Previous: Lidong Yan via GitGitGadgetNext: Lidong Yan via GitGitGadget
Message 12 of 18 in “sequencer: fix memory leak if `update_squash_messages()` failed”
  1. sequencer: fix memory leak if `update_squash_messages()` failedLidong Yan via GitGitGadget, May 14, 2025
  2. Phillip WoodMay 15, 2025
  3. Junio C HamanoMay 15, 2025
  4. lidongyanMay 15, 2025
  5. sequencer: replace error() with BUG() in update_squash_messages()Lidong Yan via GitGitGadget, May 25, 2025
  6. Junio C HamanoMay 28, 2025
  7. Phillip WoodMay 29, 2025
  8. Junio C HamanoMay 30, 2025
  9. Phillip WoodJun 2, 2025
  10. 0/2 sequencer: replace error() with BUG() in update_squash_messages()Lidong Yan via GitGitGadget, May 30, 2025
  11. 1/2 sequencer: replace error() with BUG() in update_squash_messages()Lidong Yan via GitGitGadget, May 30, 2025
  12. Junio C HamanoMay 30, 2025
  13. 2/2 BUG(): remove leading underscore of the format stringLidong Yan via GitGitGadget, May 30, 2025
  14. Junio C HamanoMay 30, 2025
  15. 0/2 sequencer: replace error() with BUG() in update_squash_messages()Lidong Yan via GitGitGadget, Jun 3, 2025
  16. 1/2 sequencer: replace error() with BUG() in update_squash_messages()Lidong Yan via GitGitGadget, Jun 3, 2025
  17. 2/2 BUG(): remove leading underscore of the format stringLidong Yan via GitGitGadget, Jun 3, 2025
  18. Junio C HamanoJun 3, 2025

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.