Re: [PATCH v2 02/34] sequencer (rebase -i): implement the 'noop' command
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 13, 2016, 21:54 UTC
- Message-ID
- <xmqqtwa7ze9i.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <CA+55aFzxFFNY+dL6s7dLZeVXBsBKD0aeof5Bj2wcD1CpefVSAA@mail.gmail.com>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 25 quoted lines
> On Tue, Dec 13, 2016 at 12:38 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Johannes Schindelin <johannes.schindelin@gmx.de> writes:
>>
>>> +/*
>>> + * Note that ordering matters in this enum. Not only must it match the mapping
>>> + * below, it is also divided into several sections that matter. When adding
>>> + * new commands, make sure you add it in the right section.
>>> + */
>>
>> Good thinking. Makes me wish C were a better language, though ;-)
>
> Do this:
>
> static const char *todo_command_strings[] = {
> [TODO_PICK] = "pick",
> [TODO_REVERT] = "revert",
> [TODO_NOOP] = "noop:,
> };
>
> which makes the array be order-independent. You still need to make
> sure you fill in all the entries, of course, but it tends to avoid at
> least one gotcha, and it makes it more obvious how the two are tied
> together.
>
> LinusYes, I know. But I do not think the variant of C we stick to is not new enough to have that.