From: Junio C Hamano <gitster@pobox.com>
To: "Beat Bolli" <bb@drbeat.li>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
Beat Bolli <dev+git@drbeat.li>
Subject: Re: [PATCH 3/3] color: add support for 12-bit RGB colors
Date: Mon, 29 Apr 2024 10:23:02 -0700 [thread overview]
Message-ID: <xmqqo79sulqh.fsf@gitster.g> (raw)
In-Reply-To: <20240429164849.78509-4-dev+git@drbeat.li> (Beat Bolli's message of "Mon, 29 Apr 2024 18:48:49 +0200")
"Beat Bolli" <bb@drbeat.li> writes:
> +static int get_hex_color(const char **inp, int width, unsigned char *out)
> {
> + const char *in = *inp;
> unsigned int val;
> - val = (hexval(in[0]) << 4) | hexval(in[1]);
> +
> + assert(width == 1 || width == 2);
> + val = (hexval(in[0]) << 4) | hexval(in[width - 1]);
So this makes #111111 out of #111 and #ffffff out of #fff. Nice.
> diff --git a/color.h b/color.h
> index bb28343be210..7ed259a35bb4 100644
> --- a/color.h
> +++ b/color.h
> @@ -112,7 +112,8 @@ int want_color_fd(int fd, int var);
> * Translate a Git color from 'value' into a string that the terminal can
> * interpret and store it into 'dst'. The Git color values are of the form
> * "foreground [background] [attr]" where fore- and background can be a color
> - * name ("red"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.
> + * name ("red"), a RGB code (#FF0000 or #F00) or a 256-color-mode from the
> + * terminal.
> */
Good. Hopefully we do not have such extra 0x in our end-user facing
documentation?
> diff --git a/t/t4026-color.sh b/t/t4026-color.sh
> index 0c39bd74a613..9a6f8a4bc5bf 100755
> --- a/t/t4026-color.sh
> +++ b/t/t4026-color.sh
> @@ -96,8 +96,8 @@ test_expect_success '256 colors' '
> color "254 bold 255" "[1;38;5;254;48;5;255m"
> '
>
> -test_expect_success '24-bit colors' '
> - color "#ff00ff black" "[38;2;255;0;255;40m"
> +test_expect_success 'RGB colors' '
> + color "#ff00ff #0f0" "[38;2;255;0;255;48;2;0;255;0m"
> '
>
> test_expect_success '"default" foreground' '
> @@ -146,7 +146,10 @@ test_expect_success 'non-hex character in RGB color' '
> invalid_color "#12x456" &&
> invalid_color "#123x56" &&
> invalid_color "#1234x6" &&
> - invalid_color "#12345x"
> + invalid_color "#12345x" &&
> + invalid_color "#x23" &&
> + invalid_color "#1x3" &&
> + invalid_color "#12x"
> '
OK, looking good.
Thanks.
next prev parent reply other threads:[~2024-04-29 17:23 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 16:48 [PATCH 0/3] color: add support for 12-bit RGB colors Beat Bolli
2024-04-29 16:48 ` [PATCH 1/3] t/t4026-color: remove an extra double quote character Beat Bolli
2024-04-30 10:59 ` Jeff King
2024-04-29 16:48 ` [PATCH 2/3] t/t4026-color: add test coverage for invalid RGB colors Beat Bolli
2024-04-29 16:48 ` [PATCH 3/3] color: add support for 12-bit " Beat Bolli
2024-04-29 17:23 ` Junio C Hamano [this message]
2024-04-29 17:42 ` Beat Bolli
2024-04-30 10:57 ` Jeff King
2024-04-30 17:31 ` Junio C Hamano
2024-04-30 18:41 ` Junio C Hamano
2024-04-30 19:01 ` Junio C Hamano
2024-05-03 17:47 ` Jeff King
2024-04-29 21:37 ` [PATCH 0/3] " Taylor Blau
2024-05-02 11:03 ` [PATCH v2 " Beat Bolli
2024-05-02 11:03 ` [PATCH v2 1/3] t/t4026-color: remove an extra double quote character Beat Bolli
2024-05-02 11:03 ` [PATCH v2 2/3] t/t4026-color: add test coverage for invalid RGB colors Beat Bolli
2024-05-02 11:03 ` [PATCH v2 3/3] color: add support for 12-bit " Beat Bolli
2024-05-02 16:29 ` [PATCH v2 0/3] " Junio C Hamano
2024-05-03 17:48 ` Jeff King
2024-05-03 19:31 ` Beat Bolli
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=xmqqo79sulqh.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=bb@drbeat.li \
--cc=dev+git@drbeat.li \
--cc=git@vger.kernel.org \
--cc=peff@peff.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.