sequencer: define array with enum values
The todo_command_info array defines which strings match with which todo_command enum values. The array is defined in the same order as the enum values, but if one changed without the other, then we would have unexpected results. Make it easier to see changes to the enum and this array by using the enum values as the indices of the array. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Jul 19, 2022 at 18:33 UTC
d7ce9a220196b995117252bb236baf135c9b704f
1 file changed
+14
-14
sequencer.c
+14
-14
@@ -1712,20 +1712,20 @@ static struct {
1712
char c;
1713
const char *str;
1714
} todo_command_info[] = {
1715
- { 'p', "pick" },
1716
- { 0, "revert" },
1717
- { 'e', "edit" },
1718
- { 'r', "reword" },
1719
- { 'f', "fixup" },
1720
- { 's', "squash" },
1721
- { 'x', "exec" },
1722
- { 'b', "break" },
1723
- { 'l', "label" },
1724
- { 't', "reset" },
1725
- { 'm', "merge" },
1726
- { 0, "noop" },
1727
- { 'd', "drop" },
1728
- { 0, NULL }
1715
+ [TODO_PICK] = { 'p', "pick" },
1716
+ [TODO_REVERT] = { 0, "revert" },
1717
+ [TODO_EDIT] = { 'e', "edit" },
1718
+ [TODO_REWORD] = { 'r', "reword" },
1719
+ [TODO_FIXUP] = { 'f', "fixup" },
1720
+ [TODO_SQUASH] = { 's', "squash" },
1721
+ [TODO_EXEC] = { 'x', "exec" },
1722
+ [TODO_BREAK] = { 'b', "break" },
1723
+ [TODO_LABEL] = { 'l', "label" },
1724
+ [TODO_RESET] = { 't', "reset" },
1725
+ [TODO_MERGE] = { 'm', "merge" },
1726
+ [TODO_NOOP] = { 0, "noop" },
1727
+ [TODO_DROP] = { 'd', "drop" },
1728
+ [TODO_COMMENT] = { 0, NULL },
1729
};
1730
1731
static const char *command_to_string(const enum todo_command command)