{"thread":{"id":"13245","subject":"[PATCH/RFC] More colors for pretty format: yellow, purple, cyan, white and black","startedAt":"2008-04-24T17:26:52Z","lastAt":"2008-04-25T20:42:08Z","messageCount":2,"participants":["Tom ten Thij","René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"75156","messageId":"c19f1c910804241026q14f95af7qa0289018d08ac23a@mail.gmail.com","threadId":"13245","inReplyTo":null,"subject":"[PATCH/RFC] More colors for pretty format: yellow, purple, cyan, white and black","fromName":"Tom ten Thij","fromEmail":"mail@tomtenthij.nl","sentAt":"2008-04-24T17:26:52Z","receivedAt":"2008-04-24T17:26:52Z","isPatch":true,"sender":{"key":"mail@tomtenthij.nl","avatar":null},"body":"Signed-off-by: Tom ten Thij <git@tomtenthij.nl>\n---\nAdd support for other colors in pretty format the same way %Cred\nworks. I reordered the if\nstatements to start with the reset case and order the others by ansi\ncolor code. Not sure if\nI have to edit other files or how to do testing for a complete patch.\n\n Documentation/pretty-formats.txt |    5 +++++\n pretty.c                         |   21 ++++++++++++++++++---\n 2 files changed, 23 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex e8bea3e..c8631f8 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -120,6 +120,11 @@ The placeholders are:\n - '%Cred': switch color to red\n - '%Cgreen': switch color to green\n - '%Cblue': switch color to blue\n+- '%Cyellow': switch color to yellow\n+- '%Cpurple': switch color to purple\n+- '%Ccyan': switch color to cyan\n+- '%Cwhite': switch color to white\n+- '%Cblack': switch color to black\n - '%Creset': reset color\n - '%m': left, right or boundary mark\n - '%n': newline\ndiff --git a/pretty.c b/pretty.c\nindex 6872932..b497008 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -471,17 +471,32 @@ static size_t format_commit_item(struct strbuf\n*sb, const char *placeholder,\n        /* these are independent of the commit */\n        switch (placeholder[0]) {\n        case 'C':\n-               if (!prefixcmp(placeholder + 1, \"red\")) {\n+               if (!prefixcmp(placeholder + 1, \"reset\")) {\n+                       strbuf_addstr(sb, \"\\033[m\");\n+                       return 6;\n+               } else if (!prefixcmp(placeholder + 1, \"black\")) {\n+                       strbuf_addstr(sb, \"\\033[30m\");\n+                       return 6;\n+               } else if (!prefixcmp(placeholder + 1, \"red\")) {\n                        strbuf_addstr(sb, \"\\033[31m\");\n                        return 4;\n                } else if (!prefixcmp(placeholder + 1, \"green\")) {\n                        strbuf_addstr(sb, \"\\033[32m\");\n                        return 6;\n+               } else if (!prefixcmp(placeholder + 1, \"yellow\")) {\n+                       strbuf_addstr(sb, \"\\033[33m\");\n+                       return 7;\n                } else if (!prefixcmp(placeholder + 1, \"blue\")) {\n                        strbuf_addstr(sb, \"\\033[34m\");\n                        return 5;\n-               } else if (!prefixcmp(placeholder + 1, \"reset\")) {\n-                       strbuf_addstr(sb, \"\\033[m\");\n+               } else if (!prefixcmp(placeholder + 1, \"purple\")) {\n+                       strbuf_addstr(sb, \"\\033[35m\");\n+                       return 7;\n+               } else if (!prefixcmp(placeholder + 1, \"cyan\")) {\n+                       strbuf_addstr(sb, \"\\033[36m\");\n+                       return 5;\n+               } else if (!prefixcmp(placeholder + 1, \"white\")) {\n+                       strbuf_addstr(sb, \"\\033[37m\");\n                        return 6;\n                } else\n                        return 0;\n-- \n1.5.4.4\n"},{"id":"75191","messageId":"48124220.50300@lsrfire.ath.cx","threadId":"13245","inReplyTo":"c19f1c910804241026q14f95af7qa0289018d08ac23a@mail.gmail.com","subject":"Re: [PATCH/RFC] More colors for pretty format: yellow, purple, cyan, white and black","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2008-04-25T20:42:08Z","receivedAt":"2008-04-25T20:42:08Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Tom ten Thij schrieb:\n> Add support for other colors in pretty format the same way %Cred\n> works.\n\nHmm.  Currently you can get the same effect by adding the escape codes\nto the format string directly.  Arguably, --pretty=format should honour\nthe  config variable color.diff and the options --color and --no-color\nto make the colour placeholders useful (both your extended set and the\ncurrent one).\n\nRené\n"}]}