Re: [PATCH 6/9] for-each-ref: add %(color:...)
From: Ramkumar Ramachandra <hidden>
Date: 2016-06-15 22:57:19
Nguyễn Thái Ngọc Duy wrote:
quoted hunk ↗ jump to hunk
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.
quoted hunk ↗ jump to hunk
/*@@ -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()?