Skip to content

Commit 3759d27

Browse files
peffgitster
authored andcommitted
parse_color: fix return value for numeric color values 0-8
When commit 695d95d refactored the color parsing, it missed a "return 0" when parsing literal numbers 0-8 (which represent basic ANSI colors), leading us to report these colors as an error. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 71b5984 commit 3759d27

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

color.c

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ static int parse_color(struct color *out, const char *name, int len)
112112
} else if (val < 8) {
113113
out->type = COLOR_ANSI;
114114
out->value = val;
115+
return 0;
115116
} else if (val < 256) {
116117
out->type = COLOR_256;
117118
out->value = val;

t/t4026-color.sh

+4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ test_expect_success 'absurdly long color specification' '
6060
"[1;2;4;5;7;22;24;25;27;38;2;255;255;255;48;2;255;255;255m"
6161
'
6262

63+
test_expect_success '0-7 are aliases for basic ANSI color names' '
64+
color "0 7" "[30;47m"
65+
'
66+
6367
test_expect_success '256 colors' '
6468
color "254 bold 255" "[1;38;5;254;48;5;255m"
6569
'

0 commit comments

Comments
 (0)