sequencer: handle multi-byte comment characters when writing todo list
commit7eb35e07c6f5616ea25601d6055c58f1220447da
authorJeff King <peff@peff.net>
Tue, 12 Mar 2024 09:17:42 +0000 (12 05:17 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 12 Mar 2024 20:28:10 +0000 (12 13:28 -0700)
tree25560d234bdc27212b69b5def6f8335d5fcda1d9
parent2ec225d397d564d9c6bb907d85a58507dec75989
sequencer: handle multi-byte comment characters when writing todo list

We already match multi-byte comment characters in parse_insn_line(),
thanks to the previous commit, yielding a TODO_COMMENT entry. But in
todo_list_to_strbuf(), we may call command_to_char() to convert that
back into something we can output.

We can't just return comment_line_char anymore, since it may require
multiple bytes. Instead, we'll return "0" for this case, which is the
same thing we'd return for a command which does not have a single-letter
abbreviation (e.g., "revert" or "noop"). There is only a single caller
of command_to_char(), and upon seeing "0" it falls back to outputting
the full name via command_to_string(). So we can handle TODO_COMMENT
there, returning the full string.

Note that there are many other callers of command_to_string(), which
will now behave differently if they pass TODO_COMMENT. But we would not
expect that to happen; prior to this commit, the function just calls
die() in this case. And looking at those callers, that makes sense;
e.g., do_pick_commit() will only be called when servicing a pick
command, and should never be called for a comment in the first place.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c