color: allow "no-" for negating attributes

Using "no-bold" rather than "nobold" is easier to read and more natural to type (to me, anyway, even though I was the person who introduced "nobold" in the first place). It's easy to allow both. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jun 23, 2016 at 13:38 UTC 5621068f3d3c537b79b76201928c0b06025479ee
3 files changed +8 -2
Documentation/config.txt
+1 -1
@@ -163,7 +163,7 @@ hex, like `#ff0ab3`.
163 The accepted attributes are `bold`, `dim`, `ul`, `blink`, and `reverse`.
164 The position of any attributes with respect to the colors (before, after,
165 or in between), doesn't matter. Specific attributes may be turned off
166 -by prefixing them with `no` (e.g., `noreverse`, `noul`, etc).
166 +by prefixing them with `no` or `no-` (e.g., `noreverse`, `no-ul`, etc).
167 +
168 For git's pre-defined color slots, the attributes are meant to be reset
169 at the beginning of each item in the colored output. So setting
color.c
+3 -1
@@ -141,8 +141,10 @@ static int parse_attr(const char *name, size_t len)
141 int negate = 0;
142 int i;
143
144 - if (skip_prefix_mem(name, len, "no", &name, &len))
144 + if (skip_prefix_mem(name, len, "no", &name, &len)) {
145 + skip_prefix_mem(name, len, "-", &name, &len);
146 negate = 1;
147 + }
148
149 for (i = 0; i < ARRAY_SIZE(attrs); i++) {
150 if (attrs[i].len == len && !memcmp(attrs[i].name, name, len))
t/t4026-color.sh
+4
@@ -50,6 +50,10 @@ test_expect_success 'attr negation' '
50 color "nobold nodim noul noblink noreverse" "[22;24;25;27m"
51 '
52
53 +test_expect_success '"no-" variant of negation' '
54 + color "no-bold no-blink" "[22;25m"
55 +'
56 +
57 test_expect_success 'long color specification' '
58 color "254 255 bold dim ul blink reverse" "[1;2;4;5;7;38;5;254;48;5;255m"
59 '