Browse Source

Merge branch 'hn/highlight-sideband-keywords'

Lines that begin with a certain keyword that come over the wire, as
well as lines that consist only of one of these keywords, ought to
be painted in color for easier eyeballing, but the latter was
broken ever since the feature was introduced in 2.19, which has
been corrected.

* hn/highlight-sideband-keywords:
  sideband: color lines with keyword only
maint
Junio C Hamano 6 years ago
parent
commit
20b3bc1558
  1. 5
      sideband.c
  2. 2
      t/t5409-colorize-remote-messages.sh

5
sideband.c

@ -87,7 +87,7 @@ static void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n) @@ -87,7 +87,7 @@ static void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)
struct keyword_entry *p = keywords + i;
int len = strlen(p->keyword);

if (n <= len)
if (n < len)
continue;
/*
* Match case insensitively, so we colorize output from existing
@ -95,7 +95,8 @@ static void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n) @@ -95,7 +95,8 @@ static void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)
* messages. We only highlight the word precisely, so
* "successful" stays uncolored.
*/
if (!strncasecmp(p->keyword, src, len) && !isalnum(src[len])) {
if (!strncasecmp(p->keyword, src, len) &&
(len == n || !isalnum(src[len]))) {
strbuf_addstr(dest, p->color);
strbuf_add(dest, src, len);
strbuf_addstr(dest, GIT_COLOR_RESET);

2
t/t5409-colorize-remote-messages.sh

@ -17,6 +17,7 @@ test_expect_success 'setup' ' @@ -17,6 +17,7 @@ test_expect_success 'setup' '
echo " " "error: leading space"
echo " "
echo Err
echo SUCCESS
exit 0
EOF
echo 1 >file &&
@ -35,6 +36,7 @@ test_expect_success 'keywords' ' @@ -35,6 +36,7 @@ test_expect_success 'keywords' '
grep "<BOLD;RED>error<RESET>: error" decoded &&
grep "<YELLOW>hint<RESET>:" decoded &&
grep "<BOLD;GREEN>success<RESET>:" decoded &&
grep "<BOLD;GREEN>SUCCESS<RESET>" decoded &&
grep "<BOLD;YELLOW>warning<RESET>:" decoded
'


Loading…
Cancel
Save