sequencer (rebase -i): differentiate between comments and 'noop'

In the upcoming patch, we will support rebase -i's progress reporting. The progress skips comments but counts 'noop's. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jan 2, 2017 at 16:34 UTC ac191470c7dba893388f4038851d68fea2094cea
1 file changed +9 -6
sequencer.c
+9 -6
@@ -737,7 +737,9 @@ enum todo_command {
737 TODO_EXEC,
738 /* commands that do nothing but are counted for reporting progress */
739 TODO_NOOP,
740 - TODO_DROP
740 + TODO_DROP,
741 + /* comments (not counted for reporting progress) */
742 + TODO_COMMENT
743 };
744
745 static struct {
@@ -752,12 +754,13 @@ static struct {
754 { 's', "squash" },
755 { 'x', "exec" },
756 { 0, "noop" },
755 - { 'd', "drop" }
757 + { 'd', "drop" },
758 + { 0, NULL }
759 };
760
761 static const char *command_to_string(const enum todo_command command)
762 {
760 - if ((size_t)command < ARRAY_SIZE(todo_command_info))
763 + if (command < TODO_COMMENT)
764 return todo_command_info[command].str;
765 die("Unknown command: %d", command);
766 }
@@ -1198,14 +1201,14 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)
1201 bol += strspn(bol, " \t");
1202
1203 if (bol == eol || *bol == '\r' || *bol == comment_line_char) {
1201 - item->command = TODO_NOOP;
1204 + item->command = TODO_COMMENT;
1205 item->commit = NULL;
1206 item->arg = bol;
1207 item->arg_len = eol - bol;
1208 return 0;
1209 }
1210
1208 - for (i = 0; i < ARRAY_SIZE(todo_command_info); i++)
1211 + for (i = 0; i < TODO_COMMENT; i++)
1212 if (skip_prefix(bol, todo_command_info[i].str, &bol)) {
1213 item->command = i;
1214 break;
@@ -1214,7 +1217,7 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)
1217 item->command = i;
1218 break;
1219 }
1217 - if (i >= ARRAY_SIZE(todo_command_info))
1220 + if (i >= TODO_COMMENT)
1221 return -1;
1222
1223 if (item->command == TODO_NOOP) {