sideband: highlight keywords in remote sideband output
v6 cover sideband: highlight keywords in remote sideband output
address Jun's comments.
Han-Wen Nienhuys (1):
sideband: highlight keywords in remote sideband output
Documentation/config.txt | 12 +++ help.c | 1 + help.h | 1 + sideband.c | 127 ++++++++++++++++++++++++++-- t/t5409-colorize-remote-messages.sh | 87 +++++++++++++++++++ 5 files changed, 219 insertions(+), 9 deletions(-) create mode 100755 t/t5409-colorize-remote-messages.sh
--
2.18.0.597.ga71716f1ad-goog
PATCH v6 1/1 sideband: highlight keywords in remote sideband output
The colorization is controlled with the config setting "color.remote".
Supported keywords are "error", "warning", "hint" and "success". They are highlighted if they appear at the start of the line, which is common in error messages, eg.
ERROR: commit is missing Change-Id
The Git push process itself prints lots of non-actionable messages (eg. bandwidth statistics, object counters for different phases of the process). This obscures actionable error messages that servers may send back. Highlighting keywords in the sideband draws more attention to those messages.
The background for this change is that Gerrit does server-side processing to create or update code reviews, and actionable error messages (eg. missing Change-Id) must be communicated back to the user during the push. User research has shown that new users have trouble seeing these messages.
The highlighting is done on the client rather than server side, so servers don't have to grow capabilities to understand terminal escape codes and terminal state. It also consistent with the current state where Git is control of the local display (eg. prefixing messages with "remote: ").
The highlighting can be configured using color.remote.<KEYWORD> configuration settings. Since the keys are matched case insensitively, we match the keywords case insensitively too.
Finally, this solution is backwards compatible: many servers already prefix their messages with "error", and they will benefit from this change without requiring a server update. By contrast, a server-side solution would likely require plumbing the TERM variable through the git protocol, so it would require changes to both server and client.
--- Documentation/config.txt | 12 +++ help.c | 1 + help.h | 1 + sideband.c | 127 ++++++++++++++++++++++++++-- t/t5409-colorize-remote-messages.sh | 87 +++++++++++++++++++ 5 files changed, 219 insertions(+), 9 deletions(-) create mode 100755 t/t5409-colorize-remote-messages.sh
Documentation/config.txt +12 -0
@@ -1263,6 +1263,18 @@ color.push:: color.push.error:: Use customized color for push errors. +color.remote:: + If set, keywords at the start of the line are highlighted. The + keywords are "error", "warning", "hint" and "success", and are + matched case-insensitively. Maybe set to `always`, `false` (or + `never`) or `auto` (or `true`). If unset, then the value of + `color.ui` is used (`auto` by default). + +color.remote.<slot>:: + Use customized color for each remote keyword. `<slot>` may be + `hint`, `warning`, `success` or `error` which match the + corresponding keyword. + color.showBranch:: A boolean to enable/disable color in the output of linkgit:git-show-branch[1]. May be set to `always`,
help.c +1 -0
@@ -425,6 +425,7 @@ void list_config_help(int for_human) { "color.diff", "<slot>", list_config_color_diff_slots }, { "color.grep", "<slot>", list_config_color_grep_slots }, { "color.interactive", "<slot>", list_config_color_interactive_slots }, + { "color.remote", "<slot>", list_config_color_sideband_slots }, { "color.status", "<slot>", list_config_color_status_slots }, { "fsck", "<msg-id>", list_config_fsck_msg_ids }, { "receive.fsck", "<msg-id>", list_config_fsck_msg_ids },
help.h +1 -0
@@ -83,6 +83,7 @@ void list_config_color_diff_slots(struct string_list *list, const char *prefix);void list_config_color_grep_slots (struct string_list *list,const char *prefix);void list_config_color_interactive_slots (struct string_list *list,const char *prefix);void list_config_color_status_slots (struct string_list *list,const char *prefix); +void list_config_color_sideband_slots (struct string_list *list,const char *prefix);void list_config_fsck_msg_ids (struct string_list *list,const char *prefix);#endif /* HELP_H */
sideband.c +118 -9
158 lines not on this page · raw message
t/t5409-colorize-remote-messages.sh new file +87 -0
87 lines not on this page · raw message
Signature · 1 line
2.18.0.597.ga71716f1ad-goog
Documentation/config.txt color.push:: · line 1266
Quoted 11 lines · Han-Wen Nienhuys
The colorization is controlled with the config setting "color.remote".
---
Documentation/config.txt +4
-0@@ -1263,6 +1263,18 @@ color.push:: +color.remote:: + If set, keywords at the start of the line are highlighted. The + keywords are "error", "warning", "hint" and "success", and are + matched case-insensitively. Maybe set to `always`, `false` (or
s/Maybe/May be/
sideband.c line 75
Quoted 8 lines
Documentation/config.txt +2
-0+ `never`) or `auto` (or `true`). If unset, then the value of + `color.ui` is used (`auto` by default).sideband.c +5
-0+static void maybe_colorize_sideband (struct strbuf *dest,const char *src,int n) +{ +if (!want_color_stderr (use_sideband_colors ())) { +strbuf_add (dest, src, n); +fprintf (stderr,"added: '%s'\n" , dest->buf);
Debugging gunk?
sideband.c int recv_sideband(const char *me, int in_stream, int out) · line 205
Quoted 5 lines
sideband.c +3
-0+return ; + }@@ -96,6 +204,7 @@ int recv_sideband(const char *me, int in_stream, int out)if (outbuf.len) { +fprintf (stderr,"last bit '%s'\n" , outbuf.buf);
Debugging gunk?
Quoted 3 lines
sideband.c +0
-0strbuf_addch (&outbuf,'\n' );xwrite (2 , outbuf.buf, outbuf.len); }