From: Dan McGee <dpmcgee@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Johan Herland <johan@herland.net>, git@vger.kernel.org
Subject: Re: [PATCH] Share color list between graph and show-branch
Date: Mon, 4 Apr 2011 19:32:05 -0500 [thread overview]
Message-ID: <BANLkTint1+c0h9DExydWeeafdgawEJPuMw@mail.gmail.com> (raw)
In-Reply-To: <7v7hbbcfoj.fsf@alter.siamese.dyndns.org>
On Sun, Apr 3, 2011 at 2:12 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Dan McGee <dpmcgee@gmail.com> writes:
>
>> diff --git a/color.h b/color.h
>> index c0528cf..a7da793 100644
>> --- a/color.h
>> +++ b/color.h
>> @@ -53,6 +53,10 @@ struct strbuf;
>> */
>> extern int git_use_color_default;
>>
>> +extern const char *column_colors_ansi[13];
>> +
>> +/* Ignore the RESET at the end when giving the size */
>> +#define COLUMN_COLORS_ANSI_MAX (ARRAY_SIZE(column_colors_ansi) - 1)
>
> Sneaky.
>
> I first went "Huh? -- this array-size macro cannot work", expecting that
> the array is not decleared with a fixed size in the header.
>
> It may make sense to unify these two palettes whose slot assignment does
> not have any meaning, but it feels that the above change totally goes
> against the spirit of using ARRAY_SIZE() macro, the point of which is to
> liberate programmers from having to count and adjust the size when adding
> the contents to the array.
>
> Wouldn't it make more sense to do something like
>
> >>> in the header <<<
> extern const char *custom_colors_ansi[];
> extern const int CUSTOM_COLORS_ANSI_MAX;
>
> >>> in the code <<<
> const char *custom_colors_ansi[] = {
> ... as before ...
> };
> /* Does not count the last element "RESET" */
> const int CUSTOM_COLORS_ANSI_MAX = ARRAY_SIZE(custom_colors_ansi) - 1;
>
> to avoid mistakes?
Duh. This makes way more sense, I'll resend the patch with the
necessary changes; I couldn't think of an elegant way to do it at the
time.
On another note, we also have this whole crazy "- 1" bit and the RESET
element at the end, and yet I see nowhere that slot is actually used.
It looks like this was introduced by commit 1e3d4119d21df28.
-Dan
next prev parent reply other threads:[~2011-04-05 0:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-31 1:38 [PATCH] Share color list between graph and show-branch Dan McGee
2011-04-03 19:12 ` Junio C Hamano
2011-04-05 0:32 ` Dan McGee [this message]
2011-04-05 5:40 ` Dan McGee
2011-04-05 7:29 ` Johan Herland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BANLkTint1+c0h9DExydWeeafdgawEJPuMw@mail.gmail.com \
--to=dpmcgee@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johan@herland.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).