git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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 &&
Previous: Han-Wen NienhuysNext: Eric Sunshine
Message 5 of 15 in “Highlight keywords in remote sideband output.”
  1. 0/2 Highlight keywords in remote sideband output.Han-Wen Nienhuys, Jul 31, 2018
  2. 1/2 Document git config getter return value.Han-Wen Nienhuys, Jul 31, 2018
  3. Eric SunshineAug 1, 2018
  4. 2/2 Highlight keywords in remote sideband output.Han-Wen Nienhuys, Jul 31, 2018
  5. Junio C HamanoJul 31, 2018
  6. Eric SunshineJul 31, 2018
  7. Junio C HamanoAug 1, 2018
  8. Han-Wen NienhuysAug 1, 2018
  9. Junio C HamanoAug 1, 2018
  10. Han-Wen NienhuysAug 2, 2018
  11. Eric SunshineAug 2, 2018
  12. Han-Wen NienhuysAug 2, 2018
  13. Eric SunshineAug 2, 2018
  14. Stefan BellerAug 2, 2018
  15. Han-Wen NienhuysAug 2, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.