| From b35ddbf9a817dc1d47f2ca888beedfbf526ffe21 Mon Sep 17 00:00:00 2001 |
| From: Alban Gruin <alban.gruin@gmail.com> |
| Date: Mon, 30 Mar 2020 14:42:35 +0200 |
| Subject: sequencer: don't abbreviate a command if it doesn't have a short form |
| |
| commit 68e7090f31b4d4f2c7b9a25240af61149fbebb5c upstream. |
| |
| 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> |
| Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> |
| --- |
| sequencer.c | 9 ++++++--- |
| 1 file changed, 6 insertions(+), 3 deletions(-) |
| |
| diff --git a/sequencer.c b/sequencer.c |
| index 24a62d5aa5d..34231780445 100644 |
| --- a/sequencer.c |
| +++ b/sequencer.c |
| @@ -1564,7 +1564,7 @@ static const char *command_to_string(const enum todo_command command) |
| |
| static char command_to_char(const enum todo_command command) |
| { |
| - if (command < TODO_COMMENT && todo_command_info[command].c) |
| + if (command < TODO_COMMENT) |
| return todo_command_info[command].c; |
| return comment_line_char; |
| } |
| @@ -4953,6 +4953,8 @@ static void todo_list_to_strbuf(struct repository *r, struct todo_list *todo_lis |
| max = num; |
| |
| for (item = todo_list->items, i = 0; i < max; i++, item++) { |
| + char cmd; |
| + |
| /* if the item is not a command write it and continue */ |
| if (item->command >= TODO_COMMENT) { |
| strbuf_addf(buf, "%.*s\n", item->arg_len, |
| @@ -4961,8 +4963,9 @@ static void todo_list_to_strbuf(struct repository *r, struct todo_list *todo_lis |
| } |
| |
| /* add command to the buffer */ |
| - if (flags & TODO_LIST_ABBREVIATE_CMDS) |
| - strbuf_addch(buf, command_to_char(item->command)); |
| + cmd = command_to_char(item->command); |
| + if ((flags & TODO_LIST_ABBREVIATE_CMDS) && cmd) |
| + strbuf_addch(buf, cmd); |
| else |
| strbuf_addstr(buf, command_to_string(item->command)); |
| |
| -- |
| 2.26.0.110.g2183baf09c |
| |