Skip to content

Commit 68e7090

Browse files
agrngitster
authored andcommitted
sequencer: don't abbreviate a command if it doesn't have a short form
When the sequencer is requested to abbreviate commands, it will replace those that do not have a short form (eg. `noop') by a comment mark. `noop' serves no purpose, except when fast-forwarding (ie. by running `git rebase'). Removing it will break this command when `rebase.abbreviateCommands' is set to true. Teach todo_list_to_strbuf() to check if a command has an actual short form, and to ignore it if not. Signed-off-by: Alban Gruin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 274b9cc commit 68e7090

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

sequencer.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@ static const char *command_to_string(const enum todo_command command)
15641564

15651565
static char command_to_char(const enum todo_command command)
15661566
{
1567-
if (command < TODO_COMMENT && todo_command_info[command].c)
1567+
if (command < TODO_COMMENT)
15681568
return todo_command_info[command].c;
15691569
return comment_line_char;
15701570
}
@@ -4947,6 +4947,8 @@ static void todo_list_to_strbuf(struct repository *r, struct todo_list *todo_lis
49474947
max = num;
49484948

49494949
for (item = todo_list->items, i = 0; i < max; i++, item++) {
4950+
char cmd;
4951+
49504952
/* if the item is not a command write it and continue */
49514953
if (item->command >= TODO_COMMENT) {
49524954
strbuf_addf(buf, "%.*s\n", item->arg_len,
@@ -4955,8 +4957,9 @@ static void todo_list_to_strbuf(struct repository *r, struct todo_list *todo_lis
49554957
}
49564958

49574959
/* add command to the buffer */
4958-
if (flags & TODO_LIST_ABBREVIATE_CMDS)
4959-
strbuf_addch(buf, command_to_char(item->command));
4960+
cmd = command_to_char(item->command);
4961+
if ((flags & TODO_LIST_ABBREVIATE_CMDS) && cmd)
4962+
strbuf_addch(buf, cmd);
49604963
else
49614964
strbuf_addstr(buf, command_to_string(item->command));
49624965

0 commit comments

Comments
 (0)