{"thread":{"id":"63456","subject":"[PATCH] sequencer: fix memory leak if `update_squash_messages()` failed","startedAt":"2025-05-14T12:44:04Z","lastAt":"2025-06-03T17:40:07Z","messageCount":18,"participants":["Lidong Yan via GitGitGadget","Phillip Wood","Junio C Hamano","lidongyan"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"518027","messageId":"pull.1964.git.git.1747226641249.gitgitgadget@gmail.com","threadId":"63456","inReplyTo":null,"subject":"[PATCH] sequencer: fix memory leak if `update_squash_messages()` failed","fromName":"Lidong Yan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-05-14T12:44:00Z","receivedAt":"2025-05-14T12:44:04Z","isPatch":true,"sender":{"key":"yldhome2d2@gmail.com","avatar":"https://avatars.githubusercontent.com/u/77328395?v=4"},"body":"From: Lidong Yan <502024330056@smail.nju.edu.cn>\n\nIn sequencer.c:update_squash_messages, `repo_logmsg_reencode` returns\neither an allocated reencode string or commit buffer if no encode is\nneeded. To free `repo_logmsg_reencode` result, `repo_unuse_commit_buffer`\nshould be used. However, when encountering the error(\"unknown command...\"),\nthe absence of `repo_unuse_commit_buffer` results in a memory leak. I\nthink we should add a `repo_unuse_commit_buffer` before return.\n\nSigned-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>\n---\n    sequencer: fix memory leak if update_squash_messages() failed\n    \n    In sequencer.c:update_squash_messages, repo_logmsg_reencode returns\n    either an allocated reencode string or commit buffer if no encode is\n    needed. To free repo_logmsg_reencode result, repo_unuse_commit_buffer\n    should be used. However, when encountering the error(\"unknown\n    command...\"), the absence of repo_unuse_commit_buffer results in a\n    memory leak. I think we should add a repo_unuse_commit_buffer before\n    return.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1964%2Fbrandb97%2Ffix-sequencer-leak-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1964/brandb97/fix-sequencer-leak-v1\nPull-Request: https://github.com/git/git/pull/1964\n\n sequencer.c | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex b5c4043757e..f288a303eaa 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -2138,8 +2138,10 @@ static int update_squash_messages(struct repository *r,\n \t\tstrbuf_addstr(&buf, \"\\n\\n\");\n \t\tstrbuf_add_commented_lines(&buf, body, strlen(body),\n \t\t\t\t\t   comment_line_str);\n-\t} else\n+\t} else {\n+\t\trepo_unuse_commit_buffer(r, commit, message);\n \t\treturn error(_(\"unknown command: %d\"), command);\n+\t}\n \trepo_unuse_commit_buffer(r, commit, message);\n \n \tif (!res)\n\nbase-commit: 6f84262c44a89851c3ae5a6e4c1a9d06b2068d75\n-- \ngitgitgadget\n"},{"id":"518089","messageId":"935822b9-33e5-457e-95a7-64058777b52a@gmail.com","threadId":"63456","inReplyTo":"pull.1964.git.git.1747226641249.gitgitgadget@gmail.com","subject":"Re: [PATCH] sequencer: fix memory leak if `update_squash_messages()` failed","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2025-05-15T10:08:36Z","receivedAt":"2025-05-15T10:09:01Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"On 14/05/2025 13:44, Lidong Yan via GitGitGadget wrote:\n> From: Lidong Yan <502024330056@smail.nju.edu.cn>\n> \n> In sequencer.c:update_squash_messages, `repo_logmsg_reencode` returns\n> either an allocated reencode string or commit buffer if no encode is\n> needed. To free `repo_logmsg_reencode` result, `repo_unuse_commit_buffer`\n> should be used. However, when encountering the error(\"unknown command...\"),\n> the absence of `repo_unuse_commit_buffer` results in a memory leak. I\n> think we should add a `repo_unuse_commit_buffer` before return.\n\nLooking at the code, if we reaching that call to error() is a \nprogramming error as we should only call update_squash_messages() if \ncommand is TODO_FIXUP or TODO_SQUASH so I think we'd be better to \nreplace error(...) with BUG(...) which calls abort() which means we \ndon't care if there is a leak or not.\n\nThanks\n\nPhillip\n\n> Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>\n> ---\n>      sequencer: fix memory leak if update_squash_messages() failed\n>      \n>      In sequencer.c:update_squash_messages, repo_logmsg_reencode returns\n>      either an allocated reencode string or commit buffer if no encode is\n>      needed. To free repo_logmsg_reencode result, repo_unuse_commit_buffer\n>      should be used. However, when encountering the error(\"unknown\n>      command...\"), the absence of repo_unuse_commit_buffer results in a\n>      memory leak. I think we should add a repo_unuse_commit_buffer before\n>      return.\n> \n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1964%2Fbrandb97%2Ffix-sequencer-leak-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1964/brandb97/fix-sequencer-leak-v1\n> Pull-Request: https://github.com/git/git/pull/1964\n> \n>   sequencer.c | 4 +++-\n>   1 file changed, 3 insertions(+), 1 deletion(-)\n> \n> diff --git a/sequencer.c b/sequencer.c\n> index b5c4043757e..f288a303eaa 100644\n> --- a/sequencer.c\n> +++ b/sequencer.c\n> @@ -2138,8 +2138,10 @@ static int update_squash_messages(struct repository *r,\n>   \t\tstrbuf_addstr(&buf, \"\\n\\n\");\n>   \t\tstrbuf_add_commented_lines(&buf, body, strlen(body),\n>   \t\t\t\t\t   comment_line_str);\n> -\t} else\n> +\t} else {\n> +\t\trepo_unuse_commit_buffer(r, commit, message);\n>   \t\treturn error(_(\"unknown command: %d\"), command);\n> +\t}\n>   \trepo_unuse_commit_buffer(r, commit, message);\n>   \n>   \tif (!res)\n> \n> base-commit: 6f84262c44a89851c3ae5a6e4c1a9d06b2068d75\n\n"},{"id":"518146","messageId":"xmqqldqx3ky7.fsf@gitster.g","threadId":"63456","inReplyTo":"935822b9-33e5-457e-95a7-64058777b52a@gmail.com","subject":"Re: [PATCH] sequencer: fix memory leak if `update_squash_messages()` failed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-15T16:20:00Z","receivedAt":"2025-05-15T16:20:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phillip Wood <phillip.wood123@gmail.com> writes:\n\n> Looking at the code, if we reaching that call to error() is a\n> programming error as we should only call update_squash_messages() if\n> command is TODO_FIXUP or TODO_SQUASH so I think we'd be better to\n> replace error(...) with BUG(...) which calls abort() which means we\n> don't care if there is a leak or not.\n\nIt is a valid way to \"fix\" a leak, certainly ;-).\n\nI am curious if Lidong's tool would notice an unreachable code if\nonly the first hunk of the attached patch is applied.  The \"else\"\nclause in the second hunk would become unreachable.\n\n\ndiff --git c/sequencer.c w/sequencer.c\nindex b5c4043757..269637d427 100644\n--- c/sequencer.c\n+++ w/sequencer.c\n@@ -2071,6 +2071,9 @@ static int update_squash_messages(struct repository *r,\n \tconst char *message, *body;\n \tconst char *encoding = get_commit_output_encoding();\n \n+\tif (!(command == TODO_FIXUP || command == TODO_SQUASH))\n+\t\tBUG(\"update_squash_messages with command %d\", command);\n+\n \tif (ctx->current_fixup_count > 0) {\n \t\tstruct strbuf header = STRBUF_INIT;\n \t\tchar *eol;\n@@ -2138,8 +2141,6 @@ static int update_squash_messages(struct repository *r,\n \t\tstrbuf_addstr(&buf, \"\\n\\n\");\n \t\tstrbuf_add_commented_lines(&buf, body, strlen(body),\n \t\t\t\t\t   comment_line_str);\n-\t} else\n-\t\treturn error(_(\"unknown command: %d\"), command);\n \trepo_unuse_commit_buffer(r, commit, message);\n \n \tif (!res)\n"},{"id":"518152","messageId":"AD5588EE-C935-42E8-9876-F47FB35309D9@smail.nju.edu.cn","threadId":"63456","inReplyTo":"xmqqldqx3ky7.fsf@gitster.g","subject":"Re: [PATCH] sequencer: fix memory leak if `update_squash_messages()` failed","fromName":"lidongyan","fromEmail":"502024330056@smail.nju.edu.cn","sentAt":"2025-05-15T16:43:04Z","receivedAt":"2025-05-15T16:43:55Z","isPatch":true,"sender":{"key":"502024330056@smail.nju.edu.cn","avatar":"https://avatars.githubusercontent.com/u/77328395?v=4"},"body":"2025年5月16日 00:20，Junio C Hamano <gitster@pobox.com> 写道：\n> \n> I am curious if Lidong's tool would notice an unreachable code if\n> only the first hunk of the attached patch is applied.  The \"else\"\n> clause in the second hunk would become unreachable.\n> \n> \n> diff --git c/sequencer.c w/sequencer.c\n> index b5c4043757..269637d427 100644\n> --- c/sequencer.c\n> +++ w/sequencer.c\n> @@ -2071,6 +2071,9 @@ static int update_squash_messages(struct repository *r,\n> const char *message, *body;\n> const char *encoding = get_commit_output_encoding();\n> \n> + if (!(command == TODO_FIXUP || command == TODO_SQUASH))\n> + BUG(\"update_squash_messages with command %d\", command);\n> +\n> if (ctx->current_fixup_count > 0) {\n> struct strbuf header = STRBUF_INIT;\n> char *eol;\n> @@ -2138,8 +2141,6 @@ static int update_squash_messages(struct repository *r,\n> strbuf_addstr(&buf, \"\\n\\n\");\n> strbuf_add_commented_lines(&buf, body, strlen(body),\n>   comment_line_str);\n> - } else\n> - return error(_(\"unknown command: %d\"), command);\n> repo_unuse_commit_buffer(r, commit, message);\n> \n> if (!res)\n\nIn this case, we do not directly identify the else branch as unreachable code.\nHowever, we perform constraint solving on the conditions leading to a potential\nleak, which ultimately allows us to determine that the leaking path is actually\nunreachable.\n\n"},{"id":"518856","messageId":"pull.1964.v2.git.git.1748168353204.gitgitgadget@gmail.com","threadId":"63456","inReplyTo":"pull.1964.git.git.1747226641249.gitgitgadget@gmail.com","subject":"[PATCH v2] sequencer: replace error() with BUG() in update_squash_messages()","fromName":"Lidong Yan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-05-25T10:19:12Z","receivedAt":"2025-05-25T10:19:16Z","isPatch":true,"sender":{"key":"yldhome2d2@gmail.com","avatar":"https://avatars.githubusercontent.com/u/77328395?v=4"},"body":"From: Lidong Yan <502024330056@smail.nju.edu.cn>\n\nIn sequencer.c, caller only pass TODO_SQUASH or TODO_FIXUP to\nupdate_squash_messages(), any other command passed in should be\nconsidered as BUG. Thus I think `return error('unknown command')`\nshould be replaced as `BUG('unknown command')`.\n\nSigned-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>\n---\n    sequencer: replace error() with BUG() in update_squash_messages()\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1964%2Fbrandb97%2Ffix-sequencer-leak-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1964/brandb97/fix-sequencer-leak-v2\nPull-Request: https://github.com/git/git/pull/1964\n\nRange-diff vs v1:\n\n 1:  a4bf7dd1cf6 ! 1:  aa5ff030b37 sequencer: fix memory leak if `update_squash_messages()` failed\n     @@ Metadata\n      Author: Lidong Yan <502024330056@smail.nju.edu.cn>\n      \n       ## Commit message ##\n     -    sequencer: fix memory leak if `update_squash_messages()` failed\n     +    sequencer: replace error() with BUG() in update_squash_messages()\n      \n     -    In sequencer.c:update_squash_messages, `repo_logmsg_reencode` returns\n     -    either an allocated reencode string or commit buffer if no encode is\n     -    needed. To free `repo_logmsg_reencode` result, `repo_unuse_commit_buffer`\n     -    should be used. However, when encountering the error(\"unknown command...\"),\n     -    the absence of `repo_unuse_commit_buffer` results in a memory leak. I\n     -    think we should add a `repo_unuse_commit_buffer` before return.\n     +    In sequencer.c, caller only pass TODO_SQUASH or TODO_FIXUP to\n     +    update_squash_messages(), any other command passed in should be\n     +    considered as BUG. Thus I think `return error('unknown command')`\n     +    should be replaced as `BUG('unknown command')`.\n      \n          Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>\n      \n       ## sequencer.c ##\n      @@ sequencer.c: static int update_squash_messages(struct repository *r,\n     - \t\tstrbuf_addstr(&buf, \"\\n\\n\");\n       \t\tstrbuf_add_commented_lines(&buf, body, strlen(body),\n       \t\t\t\t\t   comment_line_str);\n     --\t} else\n     -+\t} else {\n     -+\t\trepo_unuse_commit_buffer(r, commit, message);\n     - \t\treturn error(_(\"unknown command: %d\"), command);\n     -+\t}\n     + \t} else\n     +-\t\treturn error(_(\"unknown command: %d\"), command);\n     ++\t\tBUG(_(\"unknown command: %d\"), command);\n       \trepo_unuse_commit_buffer(r, commit, message);\n       \n       \tif (!res)\n\n\n sequencer.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex b5c4043757e..3cd0dd3434e 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -2139,7 +2139,7 @@ static int update_squash_messages(struct repository *r,\n \t\tstrbuf_add_commented_lines(&buf, body, strlen(body),\n \t\t\t\t\t   comment_line_str);\n \t} else\n-\t\treturn error(_(\"unknown command: %d\"), command);\n+\t\tBUG(_(\"unknown command: %d\"), command);\n \trepo_unuse_commit_buffer(r, commit, message);\n \n \tif (!res)\n\nbase-commit: 6f84262c44a89851c3ae5a6e4c1a9d06b2068d75\n-- \ngitgitgadget\n"},{"id":"519104","messageId":"xmqqr008peil.fsf@gitster.g","threadId":"63456","inReplyTo":"pull.1964.v2.git.git.1748168353204.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] sequencer: replace error() with BUG() in update_squash_messages()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-28T22:16:34Z","receivedAt":"2025-05-28T22:16:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Lidong Yan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Lidong Yan <502024330056@smail.nju.edu.cn>\n>\n> In sequencer.c, caller only pass TODO_SQUASH or TODO_FIXUP to\n> update_squash_messages(), any other command passed in should be\n> considered as BUG. Thus I think `return error('unknown command')`\n> should be replaced as `BUG('unknown command')`.\n\nYup.  The only caller has\n\n\telse if (is_fixup(command)) {\n\t     if (update_squash_messages(r, command, ...) {\n\nand is_fixup() is confusingly [*] defined to return true only when\nthe command is one of these two values.\n\n[Footnote]\n\n * And a similarly named is_fixup_flag() only accepts TODO_FIXUP and\n   never TODO_SQUASH.  Both of these helpers probably need to be\n   renamed.\n\n> diff --git a/sequencer.c b/sequencer.c\n> index b5c4043757e..3cd0dd3434e 100644\n> --- a/sequencer.c\n> +++ b/sequencer.c\n> @@ -2139,7 +2139,7 @@ static int update_squash_messages(struct repository *r,\n>  \t\tstrbuf_add_commented_lines(&buf, body, strlen(body),\n>  \t\t\t\t\t   comment_line_str);\n>  \t} else\n> -\t\treturn error(_(\"unknown command: %d\"), command);\n> +\t\tBUG(_(\"unknown command: %d\"), command);\n>  \trepo_unuse_commit_buffer(r, commit, message);\n\nBUG() is not end-user facing but programmer facing, and we do not\nuse _(\"...\") in them.  I see a few existing violators that need to\nbe corrected.\n\nOK.  Or\n\n\tif (!is_fixup(command))\n\t\tBUG(\"not a FIXUP or SQUASH %d\", command);\n\nat the very beginning of the function?\n"},{"id":"519138","messageId":"edd4d392-f124-4e97-b4a9-6cf3fde1e804@gmail.com","threadId":"63456","inReplyTo":"xmqqr008peil.fsf@gitster.g","subject":"Re: [PATCH v2] sequencer: replace error() with BUG() in update_squash_messages()","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2025-05-29T13:39:46Z","receivedAt":"2025-05-29T13:39:49Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"On 28/05/2025 23:16, Junio C Hamano wrote:\n> \"Lidong Yan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n> \n>> diff --git a/sequencer.c b/sequencer.c\n>> index b5c4043757e..3cd0dd3434e 100644\n>> --- a/sequencer.c\n>> +++ b/sequencer.c\n>> @@ -2139,7 +2139,7 @@ static int update_squash_messages(struct repository *r,\n>>   \t\tstrbuf_add_commented_lines(&buf, body, strlen(body),\n>>   \t\t\t\t\t   comment_line_str);\n>>   \t} else\n>> -\t\treturn error(_(\"unknown command: %d\"), command);\n>> +\t\tBUG(_(\"unknown command: %d\"), command);\n>>   \trepo_unuse_commit_buffer(r, commit, message);\n> \n> BUG() is not end-user facing but programmer facing, and we do not\n> use _(\"...\") in them.  I see a few existing violators that need to\n> be corrected.\n> \n> OK.  Or\n> \n> \tif (!is_fixup(command))\n> \t\tBUG(\"not a FIXUP or SQUASH %d\", command);\n> \n> at the very beginning of the function?\n\nAsserting the precondition at the start of the function sounds like a \ngood idea\n\nBest Wishes\n\nPhillip\n"},{"id":"519189","messageId":"pull.1964.v3.git.git.1748569955.gitgitgadget@gmail.com","threadId":"63456","inReplyTo":"pull.1964.v2.git.git.1748168353204.gitgitgadget@gmail.com","subject":"[PATCH v3 0/2] sequencer: replace error() with BUG() in update_squash_messages()","fromName":"Lidong Yan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-05-30T01:52:33Z","receivedAt":"2025-05-30T01:52:39Z","isPatch":true,"sender":{"key":"yldhome2d2@gmail.com","avatar":"https://avatars.githubusercontent.com/u/77328395?v=4"},"body":"Lidong Yan (2):\n  sequencer: replace error() with BUG() in update_squash_messages()\n  BUG(): remove leading underscore of the format string\n\n builtin/mktag.c     | 2 +-\n builtin/worktree.c  | 2 +-\n pack-bitmap-write.c | 2 +-\n sequencer.c         | 6 ++++--\n 4 files changed, 7 insertions(+), 5 deletions(-)\n\n\nbase-commit: fcfe60668e05ffde2610bfef9045797618c145ac\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1964%2Fbrandb97%2Ffix-sequencer-leak-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1964/brandb97/fix-sequencer-leak-v3\nPull-Request: https://github.com/git/git/pull/1964\n\nRange-diff vs v2:\n\n 1:  aa5ff030b37 ! 1:  b812f973d18 sequencer: replace error() with BUG() in update_squash_messages()\n     @@ Commit message\n      \n       ## sequencer.c ##\n      @@ sequencer.c: static int update_squash_messages(struct repository *r,\n     + \tconst char *message, *body;\n     + \tconst char *encoding = get_commit_output_encoding();\n     + \n     ++\tif (!is_fixup(command))\n     ++\t\tBUG(\"unknown command: %d\", command);\n     ++\n     + \tif (ctx->current_fixup_count > 0) {\n     + \t\tstruct strbuf header = STRBUF_INIT;\n     + \t\tchar *eol;\n     +@@ sequencer.c: static int update_squash_messages(struct repository *r,\n     + \t\tstrbuf_addstr(&buf, \"\\n\\n\");\n       \t\tstrbuf_add_commented_lines(&buf, body, strlen(body),\n       \t\t\t\t\t   comment_line_str);\n     - \t} else\n     +-\t} else\n      -\t\treturn error(_(\"unknown command: %d\"), command);\n     -+\t\tBUG(_(\"unknown command: %d\"), command);\n     ++\t}\n       \trepo_unuse_commit_buffer(r, commit, message);\n       \n       \tif (!res)\n -:  ----------- > 2:  e1f84c111f6 BUG(): remove leading underscore of the format string\n\n-- \ngitgitgadget\n"},{"id":"519190","messageId":"b812f973d18fbef104f2d30f4719fcc58c8578c0.1748569955.git.gitgitgadget@gmail.com","threadId":"63456","inReplyTo":"pull.1964.v3.git.git.1748569955.gitgitgadget@gmail.com","subject":"[PATCH v3 1/2] sequencer: replace error() with BUG() in update_squash_messages()","fromName":"Lidong Yan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-05-30T01:52:34Z","receivedAt":"2025-05-30T01:52:39Z","isPatch":true,"sender":{"key":"yldhome2d2@gmail.com","avatar":"https://avatars.githubusercontent.com/u/77328395?v=4"},"body":"From: Lidong Yan <502024330056@smail.nju.edu.cn>\n\nIn sequencer.c, caller only pass TODO_SQUASH or TODO_FIXUP to\nupdate_squash_messages(), any other command passed in should be\nconsidered as BUG. Thus I think `return error('unknown command')`\nshould be replaced as `BUG('unknown command')`.\n\nSigned-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>\n---\n sequencer.c | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 1ee0abbd4514..93e1732504c1 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -2067,6 +2067,9 @@ static int update_squash_messages(struct repository *r,\n \tconst char *message, *body;\n \tconst char *encoding = get_commit_output_encoding();\n \n+\tif (!is_fixup(command))\n+\t\tBUG(\"unknown command: %d\", command);\n+\n \tif (ctx->current_fixup_count > 0) {\n \t\tstruct strbuf header = STRBUF_INIT;\n \t\tchar *eol;\n@@ -2134,8 +2137,7 @@ static int update_squash_messages(struct repository *r,\n \t\tstrbuf_addstr(&buf, \"\\n\\n\");\n \t\tstrbuf_add_commented_lines(&buf, body, strlen(body),\n \t\t\t\t\t   comment_line_str);\n-\t} else\n-\t\treturn error(_(\"unknown command: %d\"), command);\n+\t}\n \trepo_unuse_commit_buffer(r, commit, message);\n \n \tif (!res)\n-- \ngitgitgadget\n\n"},{"id":"519191","messageId":"e1f84c111f6b4b5d34201ee8858a8007ea898222.1748569955.git.gitgitgadget@gmail.com","threadId":"63456","inReplyTo":"pull.1964.v3.git.git.1748569955.gitgitgadget@gmail.com","subject":"[PATCH v3 2/2] BUG(): remove leading underscore of the format string","fromName":"Lidong Yan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-05-30T01:52:35Z","receivedAt":"2025-05-30T01:52:40Z","isPatch":true,"sender":{"key":"yldhome2d2@gmail.com","avatar":"https://avatars.githubusercontent.com/u/77328395?v=4"},"body":"From: Lidong Yan <502024330056@smail.nju.edu.cn>\n\nBUG() is not end-user facing but programmer facing, and we do not\nuse _(\"...\") in them. I searched all `BUG(_` pattern and replace\nthem with `BUG(`\n\nSigned-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>\n---\n builtin/mktag.c     | 2 +-\n builtin/worktree.c  | 2 +-\n pack-bitmap-write.c | 2 +-\n 3 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 7ac11c46d53f..1b1dc0263e18 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -41,7 +41,7 @@ static int mktag_fsck_error_func(struct fsck_options *o UNUSED,\n \t\tfprintf_ln(stderr, _(\"error: tag input does not pass fsck: %s\"), message);\n \t\treturn 1;\n \tdefault:\n-\t\tBUG(_(\"%d (FSCK_IGNORE?) should never trigger this callback\"),\n+\t\tBUG(\"%d (FSCK_IGNORE?) should never trigger this callback\",\n \t\t    msg_type);\n \t}\n }\ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex 88a36ea9f867..2dceeeed8bd0 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -621,7 +621,7 @@ static void print_preparing_worktree_line(int detach,\n \t\telse {\n \t\t\tstruct commit *commit = lookup_commit_reference_by_name(branch);\n \t\t\tif (!commit)\n-\t\t\t\tBUG(_(\"unreachable: invalid reference: %s\"), branch);\n+\t\t\t\tBUG(\"unreachable: invalid reference: %s\", branch);\n \t\t\tfprintf_ln(stderr, _(\"Preparing worktree (detached HEAD %s)\"),\n \t\t\t\t  repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));\n \t\t}\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex 7f400ee01213..56960e6ad760 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -1087,7 +1087,7 @@ void bitmap_writer_finish(struct bitmap_writer *writer,\n \t\t\t\t\t oid_access);\n \n \t\tif (commit_pos < 0)\n-\t\t\tBUG(_(\"trying to write commit not in index\"));\n+\t\t\tBUG(\"trying to write commit not in index\");\n \t\tstored->commit_pos = commit_pos + base_objects;\n \t}\n \n-- \ngitgitgadget\n"},{"id":"519197","messageId":"xmqq1ps6iuw0.fsf@gitster.g","threadId":"63456","inReplyTo":"edd4d392-f124-4e97-b4a9-6cf3fde1e804@gmail.com","subject":"Re: [PATCH v2] sequencer: replace error() with BUG() in update_squash_messages()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-30T04:29:19Z","receivedAt":"2025-05-30T04:29:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phillip Wood <phillip.wood123@gmail.com> writes:\n\n>> OK.  Or\n>> \tif (!is_fixup(command))\n>> \t\tBUG(\"not a FIXUP or SQUASH %d\", command);\n>> at the very beginning of the function?\n>\n> Asserting the precondition at the start of the function sounds like a\n> good idea\n\nI am of two minds.\n\nI do not know if this is better for longer-term maintainability or\nnot.  Such a message at the beginning of the function declares that\nthe current implementation does not want to receive a command that\nis not either of these two.  Such a message tells the next developer\nwho adds another caller to the function to make sure not to pass\nother commands, which is good.\n\nBut I do not know what it tells to the next developer who wants to\nadd support for another command.  After opening that initial gate a\nbit wider, perhaps to\n\n\tif (!is_filxup(command) && !is_my_new_command(command))\n\t\tBUT(\"not a FIXUP or SQUASH or MYCOMMAND %d\", command);\n\nwould they make sure to handle their new command correctly in the\nif/elseif cascade, from which we are removing the \"error()\" with\nsuch a change, and would our reviewers notice if they forget to do\nso?  I dunno.\n\nIn any case, such a future change will have to be done with a good\nunderstanding of the entirety of this small function anyway, so I\nguess either way is OK.\n\nThanks.\n"},{"id":"519220","messageId":"xmqqbjragryw.fsf@gitster.g","threadId":"63456","inReplyTo":"e1f84c111f6b4b5d34201ee8858a8007ea898222.1748569955.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 2/2] BUG(): remove leading underscore of the format string","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-30T13:15:19Z","receivedAt":"2025-05-30T13:15:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Lidong Yan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Lidong Yan <502024330056@smail.nju.edu.cn>\n>\n> BUG() is not end-user facing but programmer facing, and we do not\n> use _(\"...\") in them. I searched all `BUG(_` pattern and replace\n> them with `BUG(`\n\nThe first sentence is good.  We'd write the second sentence more\nlike\n\n\tReplace all occurrences of BUG(_(\"...\"), ...) with\n\tBUG(\"...\", ...).\n\nI.e. you instruct somebody sitting in front of the keyboard who is\nmodifying the code for you what to do in imperative mood.\n\nThe changes themselves look good to me.\n\nThanks.\n\n> Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>\n> ---\n>  builtin/mktag.c     | 2 +-\n>  builtin/worktree.c  | 2 +-\n>  pack-bitmap-write.c | 2 +-\n>  3 files changed, 3 insertions(+), 3 deletions(-)\n>\n> diff --git a/builtin/mktag.c b/builtin/mktag.c\n> index 7ac11c46d53f..1b1dc0263e18 100644\n> --- a/builtin/mktag.c\n> +++ b/builtin/mktag.c\n> @@ -41,7 +41,7 @@ static int mktag_fsck_error_func(struct fsck_options *o UNUSED,\n>  \t\tfprintf_ln(stderr, _(\"error: tag input does not pass fsck: %s\"), message);\n>  \t\treturn 1;\n>  \tdefault:\n> -\t\tBUG(_(\"%d (FSCK_IGNORE?) should never trigger this callback\"),\n> +\t\tBUG(\"%d (FSCK_IGNORE?) should never trigger this callback\",\n>  \t\t    msg_type);\n>  \t}\n>  }\n> diff --git a/builtin/worktree.c b/builtin/worktree.c\n> index 88a36ea9f867..2dceeeed8bd0 100644\n> --- a/builtin/worktree.c\n> +++ b/builtin/worktree.c\n> @@ -621,7 +621,7 @@ static void print_preparing_worktree_line(int detach,\n>  \t\telse {\n>  \t\t\tstruct commit *commit = lookup_commit_reference_by_name(branch);\n>  \t\t\tif (!commit)\n> -\t\t\t\tBUG(_(\"unreachable: invalid reference: %s\"), branch);\n> +\t\t\t\tBUG(\"unreachable: invalid reference: %s\", branch);\n>  \t\t\tfprintf_ln(stderr, _(\"Preparing worktree (detached HEAD %s)\"),\n>  \t\t\t\t  repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));\n>  \t\t}\n> diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\n> index 7f400ee01213..56960e6ad760 100644\n> --- a/pack-bitmap-write.c\n> +++ b/pack-bitmap-write.c\n> @@ -1087,7 +1087,7 @@ void bitmap_writer_finish(struct bitmap_writer *writer,\n>  \t\t\t\t\t oid_access);\n>  \n>  \t\tif (commit_pos < 0)\n> -\t\t\tBUG(_(\"trying to write commit not in index\"));\n> +\t\t\tBUG(\"trying to write commit not in index\");\n>  \t\tstored->commit_pos = commit_pos + base_objects;\n>  \t}\n"},{"id":"519235","messageId":"xmqq7c1ygr1k.fsf@gitster.g","threadId":"63456","inReplyTo":"b812f973d18fbef104f2d30f4719fcc58c8578c0.1748569955.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 1/2] sequencer: replace error() with BUG() in update_squash_messages()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-30T13:35:19Z","receivedAt":"2025-05-30T13:35:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Lidong Yan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> @@ -2067,6 +2067,9 @@ static int update_squash_messages(struct repository *r,\n>  \tconst char *message, *body;\n>  \tconst char *encoding = get_commit_output_encoding();\n>  \n> +\tif (!is_fixup(command))\n> +\t\tBUG(\"unknown command: %d\", command);\n\nThis is not necessarily unknown.  It may be a known one like\nTODO_PICK but the reason why we are rejecting it is because it is\nnot either FIXUP or SQUASH, so we should say so.  BUG() is a message\nto our developers, so a clear message that tells them that they are\nnot supposed to pass anything but FIXUP/SQUASH is far better than\nsaying \"unknown\".\n\n>  \tif (ctx->current_fixup_count > 0) {\n>  \t\tstruct strbuf header = STRBUF_INIT;\n>  \t\tchar *eol;\n> @@ -2134,8 +2137,7 @@ static int update_squash_messages(struct repository *r,\n>  \t\tstrbuf_addstr(&buf, \"\\n\\n\");\n>  \t\tstrbuf_add_commented_lines(&buf, body, strlen(body),\n>  \t\t\t\t\t   comment_line_str);\n> -\t} else\n> -\t\treturn error(_(\"unknown command: %d\"), command);\n> +\t}\n>  \trepo_unuse_commit_buffer(r, commit, message);\n>  \n>  \tif (!res)\n"},{"id":"519463","messageId":"eba62aad-a396-46d9-9a37-3521e4e7a23e@gmail.com","threadId":"63456","inReplyTo":"xmqq1ps6iuw0.fsf@gitster.g","subject":"Re: [PATCH v2] sequencer: replace error() with BUG() in update_squash_messages()","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2025-06-02T13:59:31Z","receivedAt":"2025-06-02T13:59:34Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"On 30/05/2025 05:29, Junio C Hamano wrote:\n> Phillip Wood <phillip.wood123@gmail.com> writes:\n> \n>>> OK.  Or\n>>> \tif (!is_fixup(command))\n>>> \t\tBUG(\"not a FIXUP or SQUASH %d\", command);\n>>> at the very beginning of the function?\n>>\n>> Asserting the precondition at the start of the function sounds like a\n>> good idea\n> \n> I am of two minds.\n> \n> I do not know if this is better for longer-term maintainability or\n> not.  Such a message at the beginning of the function declares that\n> the current implementation does not want to receive a command that\n> is not either of these two.  Such a message tells the next developer\n> who adds another caller to the function to make sure not to pass\n> other commands, which is good.\n> \n> But I do not know what it tells to the next developer who wants to\n> add support for another command.  After opening that initial gate a\n> bit wider, perhaps to\n> \n> \tif (!is_filxup(command) && !is_my_new_command(command))\n> \t\tBUT(\"not a FIXUP or SQUASH or MYCOMMAND %d\", command);\n> \n> would they make sure to handle their new command correctly in the\n> if/elseif cascade, from which we are removing the \"error()\" with\n> such a change, and would our reviewers notice if they forget to do\n> so?  I dunno.\n\nI guess it cuts both ways. As you say it is a small function and I think \nsomeone adding support for a new command would need to do more that just \nchange the precondition to get their code to work unless they're calling \nthis when they don't need to.\n\n> In any case, such a future change will have to be done with a good\n> understanding of the entirety of this small function anyway, so I\n> guess either way is OK.\n\nAgreed\n\nPhillip\n"},{"id":"519522","messageId":"pull.1964.v4.git.git.1748916074.gitgitgadget@gmail.com","threadId":"63456","inReplyTo":"pull.1964.v3.git.git.1748569955.gitgitgadget@gmail.com","subject":"[PATCH v4 0/2] sequencer: replace error() with BUG() in update_squash_messages()","fromName":"Lidong Yan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-06-03T02:01:12Z","receivedAt":"2025-06-03T02:01:17Z","isPatch":true,"sender":{"key":"yldhome2d2@gmail.com","avatar":"https://avatars.githubusercontent.com/u/77328395?v=4"},"body":"Lidong Yan (2):\n  sequencer: replace error() with BUG() in update_squash_messages()\n  BUG(): remove leading underscore of the format string\n\n builtin/mktag.c     | 2 +-\n builtin/worktree.c  | 2 +-\n pack-bitmap-write.c | 2 +-\n sequencer.c         | 6 ++++--\n 4 files changed, 7 insertions(+), 5 deletions(-)\n\n\nbase-commit: fcfe60668e05ffde2610bfef9045797618c145ac\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1964%2Fbrandb97%2Ffix-sequencer-leak-v4\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1964/brandb97/fix-sequencer-leak-v4\nPull-Request: https://github.com/git/git/pull/1964\n\nRange-diff vs v3:\n\n 1:  b812f973d18 ! 1:  f2d2cfd6a87 sequencer: replace error() with BUG() in update_squash_messages()\n     @@ Commit message\n      \n          In sequencer.c, caller only pass TODO_SQUASH or TODO_FIXUP to\n          update_squash_messages(), any other command passed in should be\n     -    considered as BUG. Thus I think `return error('unknown command')`\n     -    should be replaced as `BUG('unknown command')`.\n     +    considered as BUG. Replace `return error('unknown command')`\n     +    with `BUG('not a FIXUP or SQUASH')`.\n      \n          Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>\n      \n     @@ sequencer.c: static int update_squash_messages(struct repository *r,\n       \tconst char *encoding = get_commit_output_encoding();\n       \n      +\tif (!is_fixup(command))\n     -+\t\tBUG(\"unknown command: %d\", command);\n     ++\t\tBUG(\"not a FIXUP or SQUASH %d\", command);\n      +\n       \tif (ctx->current_fixup_count > 0) {\n       \t\tstruct strbuf header = STRBUF_INIT;\n 2:  e1f84c111f6 ! 2:  9d69c19273b BUG(): remove leading underscore of the format string\n     @@ Commit message\n          BUG(): remove leading underscore of the format string\n      \n          BUG() is not end-user facing but programmer facing, and we do not\n     -    use _(\"...\") in them. I searched all `BUG(_` pattern and replace\n     -    them with `BUG(`\n     +    use _(\"...\") in them. Replace all `BUG(_(\"...\"))` with `BUG(\"...\")`\n      \n          Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>\n      \n\n-- \ngitgitgadget\n"},{"id":"519523","messageId":"f2d2cfd6a876daa6019cd82aa6bf1309f29fea83.1748916074.git.gitgitgadget@gmail.com","threadId":"63456","inReplyTo":"pull.1964.v4.git.git.1748916074.gitgitgadget@gmail.com","subject":"[PATCH v4 1/2] sequencer: replace error() with BUG() in update_squash_messages()","fromName":"Lidong Yan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-06-03T02:01:13Z","receivedAt":"2025-06-03T02:01:18Z","isPatch":true,"sender":{"key":"yldhome2d2@gmail.com","avatar":"https://avatars.githubusercontent.com/u/77328395?v=4"},"body":"From: Lidong Yan <502024330056@smail.nju.edu.cn>\n\nIn sequencer.c, caller only pass TODO_SQUASH or TODO_FIXUP to\nupdate_squash_messages(), any other command passed in should be\nconsidered as BUG. Replace `return error('unknown command')`\nwith `BUG('not a FIXUP or SQUASH')`.\n\nSigned-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>\n---\n sequencer.c | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 1ee0abbd4514..9456ca6ee97d 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -2067,6 +2067,9 @@ static int update_squash_messages(struct repository *r,\n \tconst char *message, *body;\n \tconst char *encoding = get_commit_output_encoding();\n \n+\tif (!is_fixup(command))\n+\t\tBUG(\"not a FIXUP or SQUASH %d\", command);\n+\n \tif (ctx->current_fixup_count > 0) {\n \t\tstruct strbuf header = STRBUF_INIT;\n \t\tchar *eol;\n@@ -2134,8 +2137,7 @@ static int update_squash_messages(struct repository *r,\n \t\tstrbuf_addstr(&buf, \"\\n\\n\");\n \t\tstrbuf_add_commented_lines(&buf, body, strlen(body),\n \t\t\t\t\t   comment_line_str);\n-\t} else\n-\t\treturn error(_(\"unknown command: %d\"), command);\n+\t}\n \trepo_unuse_commit_buffer(r, commit, message);\n \n \tif (!res)\n-- \ngitgitgadget\n\n"},{"id":"519524","messageId":"9d69c19273be31135eade258b49582bcc6df27c7.1748916074.git.gitgitgadget@gmail.com","threadId":"63456","inReplyTo":"pull.1964.v4.git.git.1748916074.gitgitgadget@gmail.com","subject":"[PATCH v4 2/2] BUG(): remove leading underscore of the format string","fromName":"Lidong Yan via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-06-03T02:01:14Z","receivedAt":"2025-06-03T02:01:18Z","isPatch":true,"sender":{"key":"yldhome2d2@gmail.com","avatar":"https://avatars.githubusercontent.com/u/77328395?v=4"},"body":"From: Lidong Yan <502024330056@smail.nju.edu.cn>\n\nBUG() is not end-user facing but programmer facing, and we do not\nuse _(\"...\") in them. Replace all `BUG(_(\"...\"))` with `BUG(\"...\")`\n\nSigned-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>\n---\n builtin/mktag.c     | 2 +-\n builtin/worktree.c  | 2 +-\n pack-bitmap-write.c | 2 +-\n 3 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 7ac11c46d53f..1b1dc0263e18 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -41,7 +41,7 @@ static int mktag_fsck_error_func(struct fsck_options *o UNUSED,\n \t\tfprintf_ln(stderr, _(\"error: tag input does not pass fsck: %s\"), message);\n \t\treturn 1;\n \tdefault:\n-\t\tBUG(_(\"%d (FSCK_IGNORE?) should never trigger this callback\"),\n+\t\tBUG(\"%d (FSCK_IGNORE?) should never trigger this callback\",\n \t\t    msg_type);\n \t}\n }\ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex 88a36ea9f867..2dceeeed8bd0 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -621,7 +621,7 @@ static void print_preparing_worktree_line(int detach,\n \t\telse {\n \t\t\tstruct commit *commit = lookup_commit_reference_by_name(branch);\n \t\t\tif (!commit)\n-\t\t\t\tBUG(_(\"unreachable: invalid reference: %s\"), branch);\n+\t\t\t\tBUG(\"unreachable: invalid reference: %s\", branch);\n \t\t\tfprintf_ln(stderr, _(\"Preparing worktree (detached HEAD %s)\"),\n \t\t\t\t  repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));\n \t\t}\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex 7f400ee01213..56960e6ad760 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -1087,7 +1087,7 @@ void bitmap_writer_finish(struct bitmap_writer *writer,\n \t\t\t\t\t oid_access);\n \n \t\tif (commit_pos < 0)\n-\t\t\tBUG(_(\"trying to write commit not in index\"));\n+\t\t\tBUG(\"trying to write commit not in index\");\n \t\tstored->commit_pos = commit_pos + base_objects;\n \t}\n \n-- \ngitgitgadget\n"},{"id":"519582","messageId":"xmqqcybklo5r.fsf@gitster.g","threadId":"63456","inReplyTo":"9d69c19273be31135eade258b49582bcc6df27c7.1748916074.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 2/2] BUG(): remove leading underscore of the format string","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-06-03T17:40:00Z","receivedAt":"2025-06-03T17:40:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Lidong Yan via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Lidong Yan <502024330056@smail.nju.edu.cn>\n>\n> BUG() is not end-user facing but programmer facing, and we do not\n> use _(\"...\") in them. Replace all `BUG(_(\"...\"))` with `BUG(\"...\")`\n>\n> Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>\n> ---\n>  builtin/mktag.c     | 2 +-\n>  builtin/worktree.c  | 2 +-\n>  pack-bitmap-write.c | 2 +-\n>  3 files changed, 3 insertions(+), 3 deletions(-)\n\nThis is unrelated to the sequencer code clarification change, so\nI'll queue [1/2] and [2/2] as separate topics.\n\nThanks.\n\n> diff --git a/builtin/mktag.c b/builtin/mktag.c\n> index 7ac11c46d53f..1b1dc0263e18 100644\n> --- a/builtin/mktag.c\n> +++ b/builtin/mktag.c\n> @@ -41,7 +41,7 @@ static int mktag_fsck_error_func(struct fsck_options *o UNUSED,\n>  \t\tfprintf_ln(stderr, _(\"error: tag input does not pass fsck: %s\"), message);\n>  \t\treturn 1;\n>  \tdefault:\n> -\t\tBUG(_(\"%d (FSCK_IGNORE?) should never trigger this callback\"),\n> +\t\tBUG(\"%d (FSCK_IGNORE?) should never trigger this callback\",\n>  \t\t    msg_type);\n>  \t}\n>  }\n> diff --git a/builtin/worktree.c b/builtin/worktree.c\n> index 88a36ea9f867..2dceeeed8bd0 100644\n> --- a/builtin/worktree.c\n> +++ b/builtin/worktree.c\n> @@ -621,7 +621,7 @@ static void print_preparing_worktree_line(int detach,\n>  \t\telse {\n>  \t\t\tstruct commit *commit = lookup_commit_reference_by_name(branch);\n>  \t\t\tif (!commit)\n> -\t\t\t\tBUG(_(\"unreachable: invalid reference: %s\"), branch);\n> +\t\t\t\tBUG(\"unreachable: invalid reference: %s\", branch);\n>  \t\t\tfprintf_ln(stderr, _(\"Preparing worktree (detached HEAD %s)\"),\n>  \t\t\t\t  repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));\n>  \t\t}\n> diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\n> index 7f400ee01213..56960e6ad760 100644\n> --- a/pack-bitmap-write.c\n> +++ b/pack-bitmap-write.c\n> @@ -1087,7 +1087,7 @@ void bitmap_writer_finish(struct bitmap_writer *writer,\n>  \t\t\t\t\t oid_access);\n>  \n>  \t\tif (commit_pos < 0)\n> -\t\t\tBUG(_(\"trying to write commit not in index\"));\n> +\t\t\tBUG(\"trying to write commit not in index\");\n>  \t\tstored->commit_pos = commit_pos + base_objects;\n>  \t}\n"}]}