Re: [PATCH 2/2] Highlight keywords in remote sideband output.
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 31, 2018, 19:45 UTC
- Message-ID
- <xmqqa7q7b35v.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180731173651.184716-3-hanwen@google.com>
Han-Wen Nienhuys <hanwen@google.com> writes:
Show 7 quoted lines
> The highlighting is done on the client-side. Supported keywords are > "error", "warning", "hint" and "success". > > The colorization is controlled with the config setting "color.remote". > > Co-authored-by: Duy Nguyen <pclouds@gmail.com> > Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Thanks. I'll squash the following in while queuing, though.
* maybe_colorize_sideband() does not have outside caller; make it static to avoid missing-prototype error that breaks compilation.
* correct space-before-tab whitespace style violation.
* use write_script.
* a test script must be executable to avoid triggering test-lint.
* avoid overlong lines in the test.
* no SP between redirection operator and its target.
Other than that, the result looks good to me. So that others can eyeball the result once more, I'll keep it in 'pu' for a few days, and if nothing else comes up, hopefully the topic can be merged to 'next' after that.
diff --git a/sideband.c b/sideband.c index 0d67583ec5..be4635446c 100644 --- a/sideband.c +++ b/sideband.c @@ -60,12 +60,12 @@ void list_config_color_sideband_slots(struct string_list *list, const char *pref * Optionally highlight some keywords in remote output if they appear at the * start of the line. */ -void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n) +static void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n) { int i; load_sideband_colors(); - if (!want_color_stderr(sideband_use_color)) { + if (!want_color_stderr(sideband_use_color)) { strbuf_add(dest, src, n); return; } diff --git a/t/t5409-colorize-remote-messages.sh b/t/t5409-colorize-remote-messages.sh old mode 100644 new mode 100755 index 4e1bd421ff..4547ec95b8 --- a/t/t5409-colorize-remote-messages.sh +++ b/t/t5409-colorize-remote-messages.sh @@ -6,27 +6,27 @@ test_description='remote messages are colorized on the client' test_expect_success 'setup' ' mkdir .git/hooks && - cat << EOF > .git/hooks/update && -#!/bin/sh -echo error: error -echo hint: hint -echo success: success -echo warning: warning -echo prefixerror: error -exit 0 -EOF - chmod +x .git/hooks/update && + write_script .git/hooks/update <<-\EOF && + echo error: error + echo hint: hint + echo success: success + echo warning: warning + echo prefixerror: error + exit 0 + EOF + echo 1 >file && git add file && git commit -m 1 && git clone . child && cd child && - echo 2 > file && + echo 2 >file && git commit -a -m 2 ' test_expect_success 'push' ' - git -c color.remote=always push -f origin HEAD:refs/heads/newbranch 2>output && + git -c color.remote=always \ + push -f origin HEAD:refs/heads/newbranch 2>output && test_decode_color <output >decoded && grep "<BOLD;RED>error<RESET>:" decoded && grep "<YELLOW>hint<RESET>:" decoded && @@ -36,7 +36,8 @@ test_expect_success 'push' ' ' test_expect_success 'push with customized color' ' - git -c color.remote=always -c color.remote.error=white push -f origin HEAD:refs/heads/newbranch2 2>output && + git -c color.remote=always -c color.remote.error=white \ + push -f origin HEAD:refs/heads/newbranch2 2>output && test_decode_color <output >decoded && grep "<WHITE>error<RESET>:" decoded && grep "<YELLOW>hint<RESET>:" decoded &&