@matheusbsbs / matheus-bagliano / commits / 68e7090f31
Fork 0

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 <alban.gruin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alban Gruin committed Mar 30, 2020 at 14:42 UTC 68e7090f31b4d4f2c7b9a25240af61149fbebb5c
1 file changed +6 -3
sequencer.c
+6 -3
@@ -1564,7 +1564,7 @@ static const char *command_to_string(const enum todo_command command)
1564
1565 static char command_to_char(const enum todo_command command)
1566 {
1567 - if (command < TODO_COMMENT && todo_command_info[command].c)
1567 + if (command < TODO_COMMENT)
1568 return todo_command_info[command].c;
1569 return comment_line_char;
1570 }
@@ -4947,6 +4947,8 @@ static void todo_list_to_strbuf(struct repository *r, struct todo_list *todo_lis
4947 max = num;
4948
4949 for (item = todo_list->items, i = 0; i < max; i++, item++) {
4950 + char cmd;
4951 +
4952 /* if the item is not a command write it and continue */
4953 if (item->command >= TODO_COMMENT) {
4954 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
4957 }
4958
4959 /* 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);
4963 else
4964 strbuf_addstr(buf, command_to_string(item->command));
4965