Re: [PATCH v4 8/8] rebase: cleanup action handling
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 21, 2022, 17:54 UTC
- Message-ID
- <xmqqo7u5kqov.fsf@gitster.g>
- In-Reply-To
- <ed800844ba13d143bdbc5fd0b033af96df131529.1666344108.git.gitgitgadget@gmail.com>
"Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 8 quoted lines
> From: Phillip Wood <phillip.wood@dunelm.org.uk> > > Treating the action as a string is a hang over from the scripted > rebase. The last commit removed the only remaining use of the action > that required a string so lets convert the other action users to use > the existing action enum instead. If we ever need the action name as a > string in the future the action_names array exists exactly for that > purpose.
Nice.
#leftoverbit
Perhaps a clean-up worth making after the dust settles from this series would be to use designated initialisers to avoid names and their string values going out of sync, perhaps like
static const char *action_names[] = {
[ACTION_NONE] = "undefined",
[ACTION_CONTINUE] = "continue",
...
[ACTION_SHOW_CURRENT_PATCH] = "show_current_patch",
};Unless the final element is something that must stay at the end even when adding new member to a collection, it is a good idea to keep a (seemingly unnecessary) comma at the end. That would make it easier to add a new member without unnecessary patch noise.