From: Junio C Hamano <gitster@pobox.com>
To: Han-Wen Nienhuys <hanwen@google.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/1] Highlight keywords in remote sideband output.
Date: Mon, 30 Jul 2018 14:39:50 -0700 [thread overview]
Message-ID: <xmqqsh40e72x.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20180730123334.65186-2-hanwen@google.com> (Han-Wen Nienhuys's message of "Mon, 30 Jul 2018 14:33:34 +0200")
Han-Wen Nienhuys <hanwen@google.com> writes:
> 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".
>
> Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
> ---
> sideband.c | 78 +++++++++++++++++++++++++----
> t/t5409-colorize-remote-messages.sh | 34 +++++++++++++
> 2 files changed, 103 insertions(+), 9 deletions(-)
> create mode 100644 t/t5409-colorize-remote-messages.sh
>
> diff --git a/sideband.c b/sideband.c
> index 325bf0e97..e939cd436 100644
> --- a/sideband.c
> +++ b/sideband.c
> @@ -1,7 +1,63 @@
> #include "cache.h"
> +#include "color.h"
> +#include "config.h"
> #include "pkt-line.h"
> #include "sideband.h"
>
> +
> +/*
> + * 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)
I'll make this "static" to this file while queuing. Also hoist
"struct kwtable ... keywords[]" to an earlier place in the function
to avoid decl-after-stmt error.
sideband.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/sideband.c b/sideband.c
index e939cd4360..74b2fcaf64 100644
--- a/sideband.c
+++ b/sideband.c
@@ -9,10 +9,20 @@
* 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)
{
static int sideband_use_color = -1;
int i;
+ struct kwtable {
+ const char *keyword;
+ const char *color;
+ } keywords[] = {
+ {"hint", GIT_COLOR_YELLOW},
+ {"warning", GIT_COLOR_BOLD_YELLOW},
+ {"success", GIT_COLOR_BOLD_GREEN},
+ {"error", GIT_COLOR_BOLD_RED},
+ };
+
if (sideband_use_color < 0) {
const char *key = "color.remote";
char *value = NULL;
@@ -25,16 +35,6 @@ void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)
return;
}
- struct kwtable {
- const char *keyword;
- const char *color;
- } keywords[] = {
- {"hint", GIT_COLOR_YELLOW},
- {"warning", GIT_COLOR_BOLD_YELLOW},
- {"success", GIT_COLOR_BOLD_GREEN},
- {"error", GIT_COLOR_BOLD_RED},
- };
-
while (isspace(*src)) {
strbuf_addch(dest, *src);
src++;
next prev parent reply other threads:[~2018-07-30 21:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-30 12:33 [PATCH 0/1] Highlight keywords in remote sideband output Han-Wen Nienhuys
2018-07-30 12:33 ` [PATCH 1/1] " Han-Wen Nienhuys
2018-07-30 14:52 ` Duy Nguyen
2018-07-31 1:03 ` brian m. carlson
2018-07-30 21:39 ` Junio C Hamano [this message]
2018-07-31 11:03 ` Han-Wen Nienhuys
2018-07-31 14:59 ` Junio C Hamano
2018-07-31 7:37 ` Ævar Arnfjörð Bjarmason
2018-07-31 15:06 ` Duy Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqsh40e72x.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=hanwen@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).