Re: [PATCH 6/9] for-each-ref: add %(color:...)
- From
Ramkumar Ramachandra <artagnon@gmail.com>
- Date
- May 19, 2013, 11:25 UTC
- Message-ID
- <CALkWK0md2eH+=6wEWz=x-2MwmLddFD++-ctw=Oy1O5jb7KLfrA@mail.gmail.com>
- In-Reply-To
- <1368959235-27777-7-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy wrote:
Show 10 quoted lines
> diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
> index b10d48a..db5c211 100644
> --- a/builtin/for-each-ref.c
> +++ b/builtin/for-each-ref.c
> @@ -78,6 +81,7 @@ static struct {
> { "current" },
> { "tracking" },
> { "tracking:upstream" },
> + { "color" },
> };No, I intentionally did not make color an atom in $gmane/224692. It doesn't print any information about the branch, like the other atoms do: have it augment the final printing.
Show 20 quoted lines
> /*
> @@ -707,6 +711,21 @@ static void populate_value(struct refinfo *ref)
> v->s = sb.buf;
> continue;
> }
> + else if (!prefixcmp(name, "color:")) {
> + const char *color = name + 6;
> + ref->auto_color = 0;
> + if (!prefixcmp(color, "red"))
> + v->s = GIT_COLOR_RED;
> + else if (!prefixcmp(color, "green"))
> + v->s = GIT_COLOR_GREEN;
> + else if (!prefixcmp(color, "blue"))
> + v->s = GIT_COLOR_BLUE;
> + else if (!prefixcmp(color, "reset"))
> + v->s = GIT_COLOR_RESET;
> + else if (!prefixcmp(color, "auto"))
> + ref->auto_color = 1;
> + continue;
> + }So I can't have %(color:yellow)? :( Why are you parsing it here when you can use color_parse_name()?