mbox series

[v2,0/3] color: add support for 12-bit RGB colors

Message ID 20240502110331.6347-1-dev+git@drbeat.li (mailing list archive)
Headers show
Series color: add support for 12-bit RGB colors | expand

Message

Beat Bolli May 2, 2024, 11:03 a.m. UTC
* The color parsing code learned to handle 12-bit RGB colors.

The first commit fixes a typo, the second one adds some test coverage
for invalid RGB colors, and the final one extends the RGB color parser
to recognize 12-bit colors, as in #f0f.
---

Changes against v1:
- add test coverage for invalid RGB color lengths

1:  25da18f71e2c = 1:  25da18f71e2c t/t4026-color: remove an extra double quote character
2:  fb9a6ed05279 ! 2:  352fa4c91aa0 t/t4026-color: add test coverage for invalid RGB colors
    @@ Metadata
      ## Commit message ##
         t/t4026-color: add test coverage for invalid RGB colors
     
    -    Make sure that the RGB color parser rejects invalid characters.
    +    Make sure that the RGB color parser rejects invalid characters and
    +    invalid lengths.
     
      ## t/t4026-color.sh ##
     @@ t/t4026-color.sh: test_expect_success 'extra character after attribute' '
    @@ t/t4026-color.sh: test_expect_success 'extra character after attribute' '
     +	invalid_color "#1234x6" &&
     +	invalid_color "#12345x"
     +'
    ++
    ++test_expect_success 'wrong number of letters in RGB color' '
    ++	invalid_color "#1" &&
    ++	invalid_color "#23" &&
    ++	invalid_color "#456" &&
    ++	invalid_color "#789a" &&
    ++	invalid_color "#bcdef" &&
    ++	invalid_color "#1234567"
    ++'
     +
      test_expect_success 'unknown color slots are ignored (diff)' '
      	git config color.diff.nosuchslotwilleverbedefined white &&
3:  9d109fadcdb1 ! 3:  9147902f698f color: add support for 12-bit RGB colors
    @@ t/t4026-color.sh: test_expect_success 'non-hex character in RGB color' '
     +	invalid_color "#12x"
      '
      
    - test_expect_success 'unknown color slots are ignored (diff)' '
    + test_expect_success 'wrong number of letters in RGB color' '
    + 	invalid_color "#1" &&
    + 	invalid_color "#23" &&
    +-	invalid_color "#456" &&
    + 	invalid_color "#789a" &&
    + 	invalid_color "#bcdef" &&
    + 	invalid_color "#1234567"


Beat Bolli (3):
  t/t4026-color: remove an extra double quote character
  t/t4026-color: add test coverage for invalid RGB colors
  color: add support for 12-bit RGB colors

 Documentation/config.txt |  3 ++-
 color.c                  | 21 ++++++++++++++-------
 color.h                  |  3 ++-
 t/t4026-color.sh         | 26 +++++++++++++++++++++++---
 4 files changed, 41 insertions(+), 12 deletions(-)

Comments

Junio C Hamano May 2, 2024, 4:29 p.m. UTC | #1
"Beat Bolli" <bb@drbeat.li> writes:

>  * The color parsing code learned to handle 12-bit RGB colors.
>
> The first commit fixes a typo, the second one adds some test coverage
> for invalid RGB colors, and the final one extends the RGB color parser
> to recognize 12-bit colors, as in #f0f.

Thanks.
Jeff King May 3, 2024, 5:48 p.m. UTC | #2
On Thu, May 02, 2024 at 01:03:28PM +0200, Beat Bolli wrote:

>  * The color parsing code learned to handle 12-bit RGB colors.
> 
> The first commit fixes a typo, the second one adds some test coverage
> for invalid RGB colors, and the final one extends the RGB color parser
> to recognize 12-bit colors, as in #f0f.
> ---
> 
> Changes against v1:
> - add test coverage for invalid RGB color lengths

Ah, I missed that you had sent a new version when I responded to Junio.
Yeah, this whole thing looks good to me!

-Peff
Beat Bolli May 3, 2024, 7:31 p.m. UTC | #3
On 03.05.2024 19:48, Jeff King wrote:
> On Thu, May 02, 2024 at 01:03:28PM +0200, Beat Bolli wrote:
> 
>>   * The color parsing code learned to handle 12-bit RGB colors.
>>
>> The first commit fixes a typo, the second one adds some test coverage
>> for invalid RGB colors, and the final one extends the RGB color parser
>> to recognize 12-bit colors, as in #f0f.
>> ---
>>
>> Changes against v1:
>> - add test coverage for invalid RGB color lengths
> 
> Ah, I missed that you had sent a new version when I responded to Junio.
> Yeah, this whole thing looks good to me!

All good ;-)

Thanks for reviewing!

Cheers, Beat