Re: [PATCH v2 7/8] fetch: introduce new `--output-format` option
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 27, 2023, 22:01 UTC
- Message-ID
- <xmqq8redhtn6.fsf@gitster.g>
- In-Reply-To
- <0335e5eeb4ded336c5ff7c8888c8aab9dfed2505.1682593865.git.ps@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 16 quoted lines
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 97a510649c..30099b2ac3 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -52,6 +52,13 @@ enum display_format {
> DISPLAY_FORMAT_UNKNOWN = 0,
> DISPLAY_FORMAT_FULL,
> DISPLAY_FORMAT_COMPACT,
> + DISPLAY_FORMAT_MAX,
> +};
> +
> +static const char * const display_formats[DISPLAY_FORMAT_MAX] = {
> + NULL,
> + "full",
> + "compact",
> };Hmph, the _MAX thing that is only needed to size the array and never used elsewhere (i.e. parse_display_format() uses ARRAY_SIZE() of the thing, instead of the constant, and that is just fine) is an eyesore.
I wonder if
static const char *const display_format[] = {
[DISPLAY_FORMAT_UNKNOWN] = NULL,
[DISPLAY_FORMAT_FULL] = "full",
[DISPLAY_FORMAT_COMPACT] = "compact",
};would be easier to maintain?
I'll omit my usual "name your array in singular" lecture, as I think you've heard it already.
Thanks.