{"thread":{"id":"48980","subject":"[PATCH 0/1] Highlight keywords in remote sideband output.","startedAt":"2018-07-30T12:33:41Z","lastAt":"2018-07-31T15:06:55Z","messageCount":9,"participants":["Han-Wen Nienhuys","Duy Nguyen","Junio C Hamano","brian m. carlson","Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"353869","messageId":"20180730123334.65186-1-hanwen@google.com","threadId":"48980","inReplyTo":null,"subject":"[PATCH 0/1] Highlight keywords in remote sideband output.","fromName":"Han-Wen Nienhuys","fromEmail":"hanwen@google.com","sentAt":"2018-07-30T12:33:33Z","receivedAt":"2018-07-30T12:33:41Z","isPatch":true,"sender":{"key":"hanwen@google.com","avatar":"https://avatars.githubusercontent.com/u/31547?v=4"},"body":"Made tests compile and pass (oops). Remove Change-Id footer.\n\nHan-Wen Nienhuys (1):\n  Highlight keywords in remote sideband output.\n\n sideband.c                          | 78 +++++++++++++++++++++++++----\n t/t5409-colorize-remote-messages.sh | 34 +++++++++++++\n 2 files changed, 103 insertions(+), 9 deletions(-)\n create mode 100644 t/t5409-colorize-remote-messages.sh\n\n--\n2.18.0.345.g5c9ce644c3-goog\n"},{"id":"353870","messageId":"20180730123334.65186-2-hanwen@google.com","threadId":"48980","inReplyTo":"20180730123334.65186-1-hanwen@google.com","subject":"[PATCH 1/1] Highlight keywords in remote sideband output.","fromName":"Han-Wen Nienhuys","fromEmail":"hanwen@google.com","sentAt":"2018-07-30T12:33:34Z","receivedAt":"2018-07-30T12:33:45Z","isPatch":true,"sender":{"key":"hanwen@google.com","avatar":"https://avatars.githubusercontent.com/u/31547?v=4"},"body":"The highlighting is done on the client-side. Supported keywords are\n\"error\", \"warning\", \"hint\" and \"success\".\n\nThe colorization is controlled with the config setting \"color.remote\".\n\nSigned-off-by: Han-Wen Nienhuys <hanwen@google.com>\n---\n sideband.c                          | 78 +++++++++++++++++++++++++----\n t/t5409-colorize-remote-messages.sh | 34 +++++++++++++\n 2 files changed, 103 insertions(+), 9 deletions(-)\n create mode 100644 t/t5409-colorize-remote-messages.sh\n\ndiff --git a/sideband.c b/sideband.c\nindex 325bf0e97..e939cd436 100644\n--- a/sideband.c\n+++ b/sideband.c\n@@ -1,7 +1,63 @@\n #include \"cache.h\"\n+#include \"color.h\"\n+#include \"config.h\"\n #include \"pkt-line.h\"\n #include \"sideband.h\"\n\n+\n+/*\n+ * Optionally highlight some keywords in remote output if they appear at the\n+ * start of the line.\n+ */\n+void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)\n+{\n+\tstatic int sideband_use_color = -1;\n+\tint i;\n+\tif (sideband_use_color < 0) {\n+\t\tconst char *key = \"color.remote\";\n+\t\tchar *value = NULL;\n+\t\tif (!git_config_get_string(key, &value))\n+\t\t\tsideband_use_color = git_config_colorbool(key, value);\n+\t}\n+\n+\tif (!want_color_stderr(sideband_use_color)) {\n+\t\tstrbuf_add(dest, src, n);\n+\t\treturn;\n+\t}\n+\n+\tstruct kwtable {\n+\t\tconst char *keyword;\n+\t\tconst char *color;\n+\t} keywords[] = {\n+\t\t{\"hint\", GIT_COLOR_YELLOW},\n+\t\t{\"warning\", GIT_COLOR_BOLD_YELLOW},\n+\t\t{\"success\", GIT_COLOR_BOLD_GREEN},\n+\t\t{\"error\", GIT_COLOR_BOLD_RED},\n+\t};\n+\n+\twhile (isspace(*src)) {\n+\t\tstrbuf_addch(dest, *src);\n+\t\tsrc++;\n+\t\tn--;\n+\t}\n+\n+\tfor (i = 0; i < ARRAY_SIZE(keywords); i++) {\n+\t\tstruct kwtable* p = keywords + i;\n+\t\tint len = strlen(p->keyword);\n+\t\tif (!strncasecmp(p->keyword, src, len) && !isalnum(src[len])) {\n+\t\t\tstrbuf_addstr(dest, p->color);\n+\t\t\tstrbuf_add(dest, src, len);\n+\t\t\tstrbuf_addstr(dest, GIT_COLOR_RESET);\n+\t\t\tn -= len;\n+\t\t\tsrc += len;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\tstrbuf_add(dest, src, n);\n+}\n+\n+\n /*\n  * Receive multiplexed output stream over git native protocol.\n  * in_stream is the input stream from the remote, which carries data\n@@ -48,8 +104,10 @@ int recv_sideband(const char *me, int in_stream, int out)\n \t\tlen--;\n \t\tswitch (band) {\n \t\tcase 3:\n-\t\t\tstrbuf_addf(&outbuf, \"%s%s%s\", outbuf.len ? \"\\n\" : \"\",\n-\t\t\t\t    DISPLAY_PREFIX, buf + 1);\n+\t\t\tstrbuf_addf(&outbuf, \"%s%s\", outbuf.len ? \"\\n\" : \"\",\n+\t\t\t\t    DISPLAY_PREFIX);\n+\t\t\tmaybe_colorize_sideband(&outbuf, buf + 1, len);\n+\n \t\t\tretval = SIDEBAND_REMOTE_ERROR;\n \t\t\tbreak;\n \t\tcase 2:\n@@ -69,20 +127,22 @@ int recv_sideband(const char *me, int in_stream, int out)\n \t\t\t\tif (!outbuf.len)\n \t\t\t\t\tstrbuf_addstr(&outbuf, DISPLAY_PREFIX);\n \t\t\t\tif (linelen > 0) {\n-\t\t\t\t\tstrbuf_addf(&outbuf, \"%.*s%s%c\",\n-\t\t\t\t\t\t    linelen, b, suffix, *brk);\n-\t\t\t\t} else {\n-\t\t\t\t\tstrbuf_addch(&outbuf, *brk);\n+\t\t\t\t\tmaybe_colorize_sideband(&outbuf, b, linelen);\n+\t\t\t\t\tstrbuf_addstr(&outbuf, suffix);\n \t\t\t\t}\n+\n+\t\t\t\tstrbuf_addch(&outbuf, *brk);\n \t\t\t\txwrite(2, outbuf.buf, outbuf.len);\n \t\t\t\tstrbuf_reset(&outbuf);\n\n \t\t\t\tb = brk + 1;\n \t\t\t}\n\n-\t\t\tif (*b)\n-\t\t\t\tstrbuf_addf(&outbuf, \"%s%s\", outbuf.len ?\n-\t\t\t\t\t    \"\" : DISPLAY_PREFIX, b);\n+\t\t\tif (*b) {\n+\t\t\t\tstrbuf_addstr(&outbuf, outbuf.len ?\n+\t\t\t\t\t    \"\" : DISPLAY_PREFIX);\n+\t\t\t\tmaybe_colorize_sideband(&outbuf, b, strlen(b));\n+\t\t\t}\n \t\t\tbreak;\n \t\tcase 1:\n \t\t\twrite_or_die(out, buf + 1, len);\ndiff --git a/t/t5409-colorize-remote-messages.sh b/t/t5409-colorize-remote-messages.sh\nnew file mode 100644\nindex 000000000..fd165cda0\n--- /dev/null\n+++ b/t/t5409-colorize-remote-messages.sh\n@@ -0,0 +1,34 @@\n+#!/bin/sh\n+\n+test_description='remote messages are colorized on the client'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'setup' '\n+\tmkdir .git/hooks &&\n+        cat << EOF > .git/hooks/update &&\n+#!/bin/sh\n+echo error: error\n+echo hint: hint\n+echo success: success\n+echo warning: warning\n+exit 0\n+EOF\n+\tchmod +x .git/hooks/update &&\n+\techo 1 >file &&\n+\tgit add file &&\n+\tgit commit -m 1 &&\n+        git clone . child &&\n+        cd child &&\n+        echo 2 > file &&\n+        git commit -a -m 2\n+'\n+\n+test_expect_success 'push' 'git -c color.remote=always push origin HEAD:refs/heads/newbranch 2>output &&\n+  test_decode_color < output > decoded &&\n+  test_i18ngrep \"<BOLD;RED>error<RESET>:\" decoded &&\n+  test_i18ngrep \"<YELLOW>hint<RESET>:\" decoded &&\n+  test_i18ngrep \"<BOLD;GREEN>success<RESET>:\" decoded &&\n+  test_i18ngrep \"<BOLD;YELLOW>warning<RESET>:\" decoded'\n+\n+test_done\n--\n2.18.0.345.g5c9ce644c3-goog\n"},{"id":"353881","messageId":"CACsJy8CSh5uqWepdY7wCzP024WYcRFM719uXoKzJ4oziHHxwjw@mail.gmail.com","threadId":"48980","inReplyTo":"20180730123334.65186-2-hanwen@google.com","subject":"Re: [PATCH 1/1] Highlight keywords in remote sideband output.","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-07-30T14:52:40Z","receivedAt":"2018-07-30T14:53:10Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Mon, Jul 30, 2018 at 2:34 PM Han-Wen Nienhuys <hanwen@google.com> wrote:\n> +       struct kwtable {\n> +               const char *keyword;\n> +               const char *color;\n> +       } keywords[] = {\n> +               {\"hint\", GIT_COLOR_YELLOW},\n> +               {\"warning\", GIT_COLOR_BOLD_YELLOW},\n> +               {\"success\", GIT_COLOR_BOLD_GREEN},\n> +               {\"error\", GIT_COLOR_BOLD_RED},\n> +       };\n\nPlease let me customize these colors. \"grep color.*slot\nDocumentation/config.txt help.c\" could give you a few examples.\n\nI think we also add a space after { and before } in most places (there\nare a few places that don't do that, but personally I'd prefer spaces\nto make it a bit easier to read).\n-- \nDuy\n"},{"id":"353965","messageId":"xmqqsh40e72x.fsf@gitster-ct.c.googlers.com","threadId":"48980","inReplyTo":"20180730123334.65186-2-hanwen@google.com","subject":"Re: [PATCH 1/1] Highlight keywords in remote sideband output.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-07-30T21:39:50Z","receivedAt":"2018-07-30T21:39:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Han-Wen Nienhuys <hanwen@google.com> writes:\n\n> The highlighting is done on the client-side. Supported keywords are\n> \"error\", \"warning\", \"hint\" and \"success\".\n>\n> The colorization is controlled with the config setting \"color.remote\".\n>\n> Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>\n> ---\n>  sideband.c                          | 78 +++++++++++++++++++++++++----\n>  t/t5409-colorize-remote-messages.sh | 34 +++++++++++++\n>  2 files changed, 103 insertions(+), 9 deletions(-)\n>  create mode 100644 t/t5409-colorize-remote-messages.sh\n>\n> diff --git a/sideband.c b/sideband.c\n> index 325bf0e97..e939cd436 100644\n> --- a/sideband.c\n> +++ b/sideband.c\n> @@ -1,7 +1,63 @@\n>  #include \"cache.h\"\n> +#include \"color.h\"\n> +#include \"config.h\"\n>  #include \"pkt-line.h\"\n>  #include \"sideband.h\"\n>\n> +\n> +/*\n> + * Optionally highlight some keywords in remote output if they appear at the\n> + * start of the line.\n> + */\n> +void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)\n\nI'll make this \"static\" to this file while queuing.  Also hoist\n\"struct kwtable ... keywords[]\"  to an earlier place in the function\nto avoid decl-after-stmt error.\n\n sideband.c | 22 +++++++++++-----------\n 1 file changed, 11 insertions(+), 11 deletions(-)\n\ndiff --git a/sideband.c b/sideband.c\nindex e939cd4360..74b2fcaf64 100644\n--- a/sideband.c\n+++ b/sideband.c\n@@ -9,10 +9,20 @@\n  * Optionally highlight some keywords in remote output if they appear at the\n  * start of the line.\n  */\n-void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)\n+static void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)\n {\n \tstatic int sideband_use_color = -1;\n \tint i;\n+\tstruct kwtable {\n+\t\tconst char *keyword;\n+\t\tconst char *color;\n+\t} keywords[] = {\n+\t\t{\"hint\", GIT_COLOR_YELLOW},\n+\t\t{\"warning\", GIT_COLOR_BOLD_YELLOW},\n+\t\t{\"success\", GIT_COLOR_BOLD_GREEN},\n+\t\t{\"error\", GIT_COLOR_BOLD_RED},\n+\t};\n+\n \tif (sideband_use_color < 0) {\n \t\tconst char *key = \"color.remote\";\n \t\tchar *value = NULL;\n@@ -25,16 +35,6 @@ void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)\n \t\treturn;\n \t}\n \n-\tstruct kwtable {\n-\t\tconst char *keyword;\n-\t\tconst char *color;\n-\t} keywords[] = {\n-\t\t{\"hint\", GIT_COLOR_YELLOW},\n-\t\t{\"warning\", GIT_COLOR_BOLD_YELLOW},\n-\t\t{\"success\", GIT_COLOR_BOLD_GREEN},\n-\t\t{\"error\", GIT_COLOR_BOLD_RED},\n-\t};\n-\n \twhile (isspace(*src)) {\n \t\tstrbuf_addch(dest, *src);\n \t\tsrc++;\n"},{"id":"353992","messageId":"20180731010312.GA45452@genre.crustytoothpaste.net","threadId":"48980","inReplyTo":"CACsJy8CSh5uqWepdY7wCzP024WYcRFM719uXoKzJ4oziHHxwjw@mail.gmail.com","subject":"Re: [PATCH 1/1] Highlight keywords in remote sideband output.","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-31T01:03:12Z","receivedAt":"2018-07-31T01:03:20Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Mon, Jul 30, 2018 at 04:52:40PM +0200, Duy Nguyen wrote:\n> On Mon, Jul 30, 2018 at 2:34 PM Han-Wen Nienhuys <hanwen@google.com> wrote:\n> > +       struct kwtable {\n> > +               const char *keyword;\n> > +               const char *color;\n> > +       } keywords[] = {\n> > +               {\"hint\", GIT_COLOR_YELLOW},\n> > +               {\"warning\", GIT_COLOR_BOLD_YELLOW},\n> > +               {\"success\", GIT_COLOR_BOLD_GREEN},\n> > +               {\"error\", GIT_COLOR_BOLD_RED},\n> > +       };\n> \n> Please let me customize these colors. \"grep color.*slot\n> Documentation/config.txt help.c\" could give you a few examples.\n\nYes, please.  I use a transparent terminal and I have trouble seeing the\ndefault red in some cases due to lack of contrast, and some people with\ncertain forms of colorblindness may be unable to distinguish these three\ncolors at all.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"354001","messageId":"87tvofua7k.fsf@evledraar.gmail.com","threadId":"48980","inReplyTo":"20180730123334.65186-2-hanwen@google.com","subject":"Re: [PATCH 1/1] Highlight keywords in remote sideband output.","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-07-31T07:37:51Z","receivedAt":"2018-07-31T07:37:56Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Mon, Jul 30 2018, Han-Wen Nienhuys wrote:\n\n\n> +\tif (sideband_use_color < 0) {\n> +\t\tconst char *key = \"color.remote\";\n> +\t\tchar *value = NULL;\n> +\t\tif (!git_config_get_string(key, &value))\n> +\t\t\tsideband_use_color = git_config_colorbool(key, value);\n> [...]\n> +\tstruct kwtable {\n> +\t\tconst char *keyword;\n> +\t\tconst char *color;\n> +\t} keywords[] = {\n> +\t\t{\"hint\", GIT_COLOR_YELLOW},\n> +\t\t{\"warning\", GIT_COLOR_BOLD_YELLOW},\n> +\t\t{\"success\", GIT_COLOR_BOLD_GREEN},\n> +\t\t{\"error\", GIT_COLOR_BOLD_RED},\n\n\nFWIW I agree with other reviewers that it would be nice if these could\nbe customized, but I also think it can wait for some follow-up patch.\n\nUsers who don't like these colors don't have to use them, and then\nthey're no worse off than now, whereas some users will appreciate these\nand be better off than now.\n\nSo great if you want to improve this, but just chiming in on that point\nbecause I think we should be respectful of the time of contributors, and\nnot make perfect the enemy of the good.\n\n> +test_expect_success 'setup' '\n> +\tmkdir .git/hooks &&\n> +        cat << EOF > .git/hooks/update &&\n\nIt's the coding style of git.git to snuggle the \">\" with the\nfilename. I.e. \"<<EOF >file\", not \"<< EOF > file\". Same for the other\noccurrences of \">\" etc. below.\n\n> +#!/bin/sh\n> +echo error: error\n> +echo hint: hint\n> +echo success: success\n> +echo warning: warning\n\nHere I think it makes sense to more exhaustively test the sort of output\nwe do and don't hilight, both for regression testing and to explain this\nin code. E.g. let's do all of these:\n\n    error: text\n    hint: text\n    success: text\n    warning: text\n\n    PREFIXerror: text\n    PREFIXhint: text\n    PREFIXsuccess: text\n    PREFIXwarning: text\n\n    errorSUFFIX: text\n    hintSUFFIX: text\n    successSUFFIX: text\n    warningSUFFIX: text\n\n\tthis is an error: text\n\tthis is a hint: text\n\tthis is success: text\n\tthis is a warning: text\n\n> +test_expect_success 'push' 'git -c color.remote=always push origin HEAD:refs/heads/newbranch 2>output &&\n> +  test_decode_color < output > decoded &&\n> +  test_i18ngrep \"<BOLD;RED>error<RESET>:\" decoded &&\n> +  test_i18ngrep \"<YELLOW>hint<RESET>:\" decoded &&\n> +  test_i18ngrep \"<BOLD;GREEN>success<RESET>:\" decoded &&\n> +  test_i18ngrep \"<BOLD;YELLOW>warning<RESET>:\" decoded'\n\nI think this is a case where we want just \"grep\", not \"test_i18ngrep\",\nthat output you just emitted won't be translated.\n"},{"id":"354013","messageId":"CAFQ2z_NL+8LVmv+E4osq2+nx+qVE4P80it8vjLUwib=HJ5k4Lg@mail.gmail.com","threadId":"48980","inReplyTo":"xmqqsh40e72x.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH 1/1] Highlight keywords in remote sideband output.","fromName":"Han-Wen Nienhuys","fromEmail":"hanwen@google.com","sentAt":"2018-07-31T11:03:53Z","receivedAt":"2018-07-31T11:04:07Z","isPatch":true,"sender":{"key":"hanwen@google.com","avatar":"https://avatars.githubusercontent.com/u/31547?v=4"},"body":"On Mon, Jul 30, 2018 at 11:39 PM Junio C Hamano <gitster@pobox.com> wrote:\n> > + */\n> > +void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)\n>\n> I'll make this \"static\" to this file while queuing.\n\nDoes that mean the patch is in?\n\n\n\n--\n\nGoogle Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich\n\nRegistergericht und -nummer: Hamburg, HRB 86891\n\nSitz der Gesellschaft: Hamburg\n\nGeschäftsführer: Paul Manicle, Halimah DeLaine Prado\n"},{"id":"354038","messageId":"xmqqd0v3e9iz.fsf@gitster-ct.c.googlers.com","threadId":"48980","inReplyTo":"CAFQ2z_NL+8LVmv+E4osq2+nx+qVE4P80it8vjLUwib=HJ5k4Lg@mail.gmail.com","subject":"Re: [PATCH 1/1] Highlight keywords in remote sideband output.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-07-31T14:59:16Z","receivedAt":"2018-07-31T14:59:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Han-Wen Nienhuys <hanwen@google.com> writes:\n\n> On Mon, Jul 30, 2018 at 11:39 PM Junio C Hamano <gitster@pobox.com> wrote:\n>> > + */\n>> > +void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)\n>>\n>> I'll make this \"static\" to this file while queuing.\n>\n> Does that mean the patch is in?\n\nIt depends on your definition of \"is in\".  \n\nIt does not mean there is no need to update it further before it\ngraduates to 'master' and becomes part of the next release, if that\nis what you are asking.\n\nI saw others commented on the patch, showing general interest in the\nfeature, agreeing to the approach taken and suggesting improvements.\nI am *not* going to respond to these comments and make further\nchanges myself (you hopefully will), but expect that these review\ndiscussions to find a good terminal point that results in your\nsending out the \"hopefully the final best version\" in some time.  In\nthe meantime while I am waiting for that, I'd hold onto the version\nposted here and build it with all topics in flight that are waiting\nfor improvements in a similar way by merging it in the 'pu' branch.\nAnd while doing so, I'll minimally modify this initial version so\nthat the whole thing at least compiles, by making small tweaks like\nmaking a function that should be static static and getting rid of\ndecl-after-stmt, etc.\n\nThat is what I meant by that line, and nothing more.\n\nThanks.\n"},{"id":"354041","messageId":"20180731150648.GA852@duynguyen.home","threadId":"48980","inReplyTo":"87tvofua7k.fsf@evledraar.gmail.com","subject":"Re: [PATCH 1/1] Highlight keywords in remote sideband output.","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-07-31T15:06:48Z","receivedAt":"2018-07-31T15:06:55Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Jul 31, 2018 at 09:37:51AM +0200, Ævar Arnfjörð Bjarmason wrote:\n> \n> On Mon, Jul 30 2018, Han-Wen Nienhuys wrote:\n> \n> \n> > +\tif (sideband_use_color < 0) {\n> > +\t\tconst char *key = \"color.remote\";\n> > +\t\tchar *value = NULL;\n> > +\t\tif (!git_config_get_string(key, &value))\n> > +\t\t\tsideband_use_color = git_config_colorbool(key, value);\n> > [...]\n> > +\tstruct kwtable {\n> > +\t\tconst char *keyword;\n> > +\t\tconst char *color;\n> > +\t} keywords[] = {\n> > +\t\t{\"hint\", GIT_COLOR_YELLOW},\n> > +\t\t{\"warning\", GIT_COLOR_BOLD_YELLOW},\n> > +\t\t{\"success\", GIT_COLOR_BOLD_GREEN},\n> > +\t\t{\"error\", GIT_COLOR_BOLD_RED},\n> \n> \n> FWIW I agree with other reviewers that it would be nice if these could\n> be customized, but I also think it can wait for some follow-up patch.\n> \n> Users who don't like these colors don't have to use them, and then\n> they're no worse off than now, whereas some users will appreciate these\n> and be better off than now.\n> \n> So great if you want to improve this, but just chiming in on that point\n> because I think we should be respectful of the time of contributors, and\n> not make perfect the enemy of the good.\n\nFair enough. I'll scratch my own itch. Can we squash this in then?\n\n-- 8< --\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 43b2de7b5f..0783323bec 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1229,6 +1229,15 @@ color.push::\n color.push.error::\n \tUse customized color for push errors.\n \n+color.remote::\n+\tA boolean to enable/disable colored remote output. If unset,\n+\tthen the value of `color.ui` is used (`auto` by default).\n+\n+color.remote.<slot>::\n+\tUse customized color for each remote keywords. `<slot>` may be\n+\t`hint`, `warning`, `success` or `error` which match the\n+\tcorresponding keyword.\n+\n color.showBranch::\n \tA boolean to enable/disable color in the output of\n \tlinkgit:git-show-branch[1]. May be set to `always`,\ndiff --git a/help.c b/help.c\nindex 3ebf0568db..b6cafcfc0a 100644\n--- a/help.c\n+++ b/help.c\n@@ -425,6 +425,7 @@ void list_config_help(int for_human)\n \t\t{ \"color.diff\", \"<slot>\", list_config_color_diff_slots },\n \t\t{ \"color.grep\", \"<slot>\", list_config_color_grep_slots },\n \t\t{ \"color.interactive\", \"<slot>\", list_config_color_interactive_slots },\n+\t\t{ \"color.remote\", \"<slot>\", list_config_color_sideband_slots },\n \t\t{ \"color.status\", \"<slot>\", list_config_color_status_slots },\n \t\t{ \"fsck\", \"<msg-id>\", list_config_fsck_msg_ids },\n \t\t{ \"receive.fsck\", \"<msg-id>\", list_config_fsck_msg_ids },\ndiff --git a/help.h b/help.h\nindex f8b15323a6..9eab6a3f89 100644\n--- a/help.h\n+++ b/help.h\n@@ -83,6 +83,7 @@ void list_config_color_diff_slots(struct string_list *list, const char *prefix);\n void list_config_color_grep_slots(struct string_list *list, const char *prefix);\n void list_config_color_interactive_slots(struct string_list *list, const char *prefix);\n void list_config_color_status_slots(struct string_list *list, const char *prefix);\n+void list_config_color_sideband_slots(struct string_list *list, const char *prefix);\n void list_config_fsck_msg_ids(struct string_list *list, const char *prefix);\n \n #endif /* HELP_H */\ndiff --git a/sideband.c b/sideband.c\nindex 74b2fcaf64..61c4376a64 100644\n--- a/sideband.c\n+++ b/sideband.c\n@@ -3,7 +3,59 @@\n #include \"config.h\"\n #include \"pkt-line.h\"\n #include \"sideband.h\"\n+#include \"help.h\"\n+\n+struct kwtable {\n+\t/*\n+\t * Note, we current use keyword as config key so it can't\n+\t * contain funny chars like spaces. When we do that, we need a\n+\t * separate field for slot name in load_sideband_colors().\n+\t */\n+\tconst char *keyword;\n+\tchar color[COLOR_MAXLEN];\n+};\n+\n+static struct kwtable keywords[] = {\n+\t{ \"hint\",\tGIT_COLOR_YELLOW },\n+\t{ \"warning\",\tGIT_COLOR_BOLD_YELLOW },\n+\t{ \"success\",\tGIT_COLOR_BOLD_GREEN },\n+\t{ \"error\",\tGIT_COLOR_BOLD_RED },\n+};\n+\n+static int sideband_use_color = -1;\n+\n+static void load_sideband_colors(void)\n+{\n+\tconst char *key = \"color.remote\";\n+\tstruct strbuf sb = STRBUF_INIT;\n+\tchar *value;\n+\tint i;\n+\n+\tif (sideband_use_color >= 0)\n+\t\treturn;\n+\n+\tif (!git_config_get_string(key, &value))\n+\t\tsideband_use_color = git_config_colorbool(key, value);\n+\n+\tfor (i = 0; i < ARRAY_SIZE(keywords); i++) {\n+\t\tstrbuf_reset(&sb);\n+\t\tstrbuf_addf(&sb, \"%s.%s\", key, keywords[i].keyword);\n+\t\tif (git_config_get_string(sb.buf, &value))\n+\t\t\tcontinue;\n+\n+\t\tif (color_parse(value, keywords[i].color))\n+\t\t\tdie(_(\"expecting a color: %s\"), value);\n+\t}\n+\tstrbuf_release(&sb);\n+}\n+\n+void list_config_color_sideband_slots(struct string_list *list, const char *prefix)\n+{\n+\tint i;\n \n+\tfor (i = 0; i < ARRAY_SIZE(keywords); i++)\n+\t\tlist_config_item(list, prefix, keywords[i].keyword);\n+}\n \n /*\n  * Optionally highlight some keywords in remote output if they appear at the\n@@ -11,24 +63,9 @@\n  */\n static void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)\n {\n-\tstatic int sideband_use_color = -1;\n \tint i;\n-\tstruct kwtable {\n-\t\tconst char *keyword;\n-\t\tconst char *color;\n-\t} keywords[] = {\n-\t\t{\"hint\", GIT_COLOR_YELLOW},\n-\t\t{\"warning\", GIT_COLOR_BOLD_YELLOW},\n-\t\t{\"success\", GIT_COLOR_BOLD_GREEN},\n-\t\t{\"error\", GIT_COLOR_BOLD_RED},\n-\t};\n-\n-\tif (sideband_use_color < 0) {\n-\t\tconst char *key = \"color.remote\";\n-\t\tchar *value = NULL;\n-\t\tif (!git_config_get_string(key, &value))\n-\t\t\tsideband_use_color = git_config_colorbool(key, value);\n-\t}\n+\n+\tload_sideband_colors();\n \n \tif (!want_color_stderr(sideband_use_color)) {\n \t\tstrbuf_add(dest, src, n);\ndiff --git a/t/t5409-colorize-remote-messages.sh b/t/t5409-colorize-remote-messages.sh\nindex 606386f4fe..69b7cc571d 100755\n--- a/t/t5409-colorize-remote-messages.sh\n+++ b/t/t5409-colorize-remote-messages.sh\n@@ -6,7 +6,7 @@ test_description='remote messages are colorized on the client'\n \n test_expect_success 'setup' '\n \tmkdir .git/hooks &&\n-\tcat << EOF > .git/hooks/update &&\n+\tcat << EOF >.git/hooks/update &&\n #!/bin/sh\n echo error: error\n echo hint: hint\n@@ -20,15 +20,26 @@ EOF\n \tgit commit -m 1 &&\n \tgit clone . child &&\n \tcd child &&\n-\techo 2 > file &&\n+\techo 2 >file &&\n \tgit commit -a -m 2\n '\n \n-test_expect_success 'push' 'git -c color.remote=always push origin HEAD:refs/heads/newbranch 2>output &&\n-  test_decode_color < output > decoded &&\n-  test_i18ngrep \"<BOLD;RED>error<RESET>:\" decoded &&\n-  test_i18ngrep \"<YELLOW>hint<RESET>:\" decoded &&\n-  test_i18ngrep \"<BOLD;GREEN>success<RESET>:\" decoded &&\n-  test_i18ngrep \"<BOLD;YELLOW>warning<RESET>:\" decoded'\n+test_expect_success 'push' '\n+\tgit -c color.remote=always push origin HEAD:refs/heads/newbranch 2>output &&\n+\ttest_decode_color <output >decoded &&\n+\ttest_i18ngrep \"<BOLD;RED>error<RESET>:\" decoded &&\n+\ttest_i18ngrep \"<YELLOW>hint<RESET>:\" decoded &&\n+\ttest_i18ngrep \"<BOLD;GREEN>success<RESET>:\" decoded &&\n+\ttest_i18ngrep \"<BOLD;YELLOW>warning<RESET>:\" decoded\n+'\n+\n+test_expect_success 'push with customized color' '\n+\tgit -c color.remote=always -c color.remote.error=white push origin HEAD:refs/heads/newbranch2 2>output &&\n+\ttest_decode_color <output >decoded &&\n+\ttest_i18ngrep \"<WHITE>error<RESET>:\" decoded &&\n+\ttest_i18ngrep \"<YELLOW>hint<RESET>:\" decoded &&\n+\ttest_i18ngrep \"<BOLD;GREEN>success<RESET>:\" decoded &&\n+\ttest_i18ngrep \"<BOLD;YELLOW>warning<RESET>:\" decoded\n+'\n \n test_done\n-- 8< --\n"}]}