提交 3759d27a 编写于 作者: J Jeff King 提交者: Junio C Hamano

parse_color: fix return value for numeric color values 0-8

When commit 695d95df 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: NJeff King <peff@peff.net>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 71b59849
...@@ -112,6 +112,7 @@ static int parse_color(struct color *out, const char *name, int len) ...@@ -112,6 +112,7 @@ static int parse_color(struct color *out, const char *name, int len)
} else if (val < 8) { } else if (val < 8) {
out->type = COLOR_ANSI; out->type = COLOR_ANSI;
out->value = val; out->value = val;
return 0;
} else if (val < 256) { } else if (val < 256) {
out->type = COLOR_256; out->type = COLOR_256;
out->value = val; out->value = val;
......
...@@ -60,6 +60,10 @@ test_expect_success 'absurdly long color specification' ' ...@@ -60,6 +60,10 @@ test_expect_success 'absurdly long color specification' '
"[1;2;4;5;7;22;24;25;27;38;2;255;255;255;48;2;255;255;255m" "[1;2;4;5;7;22;24;25;27;38;2;255;255;255;48;2;255;255;255m"
' '
test_expect_success '0-7 are aliases for basic ANSI color names' '
color "0 7" "[30;47m"
'
test_expect_success '256 colors' ' test_expect_success '256 colors' '
color "254 bold 255" "[1;38;5;254;48;5;255m" color "254 bold 255" "[1;38;5;254;48;5;255m"
' '
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册