sequencer: replace error() with BUG() in update_squash_messages ()
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. Replace `return error('unknown command')` with `BUG('not a FIXUP or SQUASH')`. Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Lidong Yan committed
Jun 3, 2025 at 02:01 UTC
8b34b6a22038765e601692bee2e299eea14441d6
1 file changed
+4
-2
sequencer.c
+4
-2
@@ -2067,6 +2067,9 @@ static int update_squash_messages(struct repository *r,
2067
const char *message, *body;
2068
const char *encoding = get_commit_output_encoding();
2069
2070
+ if (!is_fixup(command))
2071
+ BUG("not a FIXUP or SQUASH %d", command);
2072
+
2073
if (ctx->current_fixup_count > 0) {
2074
struct strbuf header = STRBUF_INIT;
2075
char *eol;
@@ -2134,8 +2137,7 @@ static int update_squash_messages(struct repository *r,
2137
strbuf_addstr(&buf, "\n\n");
2138
strbuf_add_commented_lines(&buf, body, strlen(body),
2139
comment_line_str);
2137
- } else
2138
- return error(_("unknown command: %d"), command);
2140
+ }
2141
repo_unuse_commit_buffer(r, commit, message);
2142
2143
if (!res)