Skip to content

Commit 7eb35e0

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2ec225d commit 7eb35e0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sequencer.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1779,14 +1779,16 @@ static const char *command_to_string(const enum todo_command command)
17791779
{
17801780
if (command < TODO_COMMENT)
17811781
return todo_command_info[command].str;
1782+
if (command == TODO_COMMENT)
1783+
return comment_line_str;
17821784
die(_("unknown command: %d"), command);
17831785
}
17841786

17851787
static char command_to_char(const enum todo_command command)
17861788
{
17871789
if (command < TODO_COMMENT)
17881790
return todo_command_info[command].c;
1789-
return comment_line_char;
1791+
return 0;
17901792
}
17911793

17921794
static int is_noop(const enum todo_command command)

0 commit comments

Comments
 (0)