[PATCH v3 1/2] sequencer: replace error() with BUG() in update_squash_messages()
- From
Lidong Yan via GitGitGadget <gitgitgadget@gmail.com>
- Date
- May 30, 2025, 01:52 UTC
- Message-ID
- <b812f973d18fbef104f2d30f4719fcc58c8578c0.1748569955.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1964.v3.git.git.1748569955.gitgitgadget@gmail.com>
From: Lidong Yan <502024330056@smail.nju.edu.cn>
In sequencer.c, caller only pass TODO_SQUASH or TODO_FIXUP to update_squash_messages(), any other command passed in should be considered as BUG. Thus I think `return error('unknown command')` should be replaced as `BUG('unknown command')`.
Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> --- sequencer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sequencer.c b/sequencer.c index 1ee0abbd4514..93e1732504c1 100644 --- a/sequencer.c +++ b/sequencer.c @@ -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); + 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)
-- gitgitgadget