Skip to content

Commit d7ce9a2

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f57fd48 commit d7ce9a2

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

sequencer.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,20 +1712,20 @@ static struct {
17121712
char c;
17131713
const char *str;
17141714
} 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 },
17291729
};
17301730

17311731
static const char *command_to_string(const enum todo_command command)

0 commit comments

Comments
 (0)