Skip to content

Commit 20b3bc1

Browse files
committed
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
2 parents edb3273 + 1f67290 commit 20b3bc1

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

sideband.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,16 @@ static void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)
8787
struct keyword_entry *p = keywords + i;
8888
int len = strlen(p->keyword);
8989

90-
if (n <= len)
90+
if (n < len)
9191
continue;
9292
/*
9393
* Match case insensitively, so we colorize output from existing
9494
* servers regardless of the case that they use for their
9595
* messages. We only highlight the word precisely, so
9696
* "successful" stays uncolored.
9797
*/
98-
if (!strncasecmp(p->keyword, src, len) && !isalnum(src[len])) {
98+
if (!strncasecmp(p->keyword, src, len) &&
99+
(len == n || !isalnum(src[len]))) {
99100
strbuf_addstr(dest, p->color);
100101
strbuf_add(dest, src, len);
101102
strbuf_addstr(dest, GIT_COLOR_RESET);

t/t5409-colorize-remote-messages.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ test_expect_success 'setup' '
1717
echo " " "error: leading space"
1818
echo " "
1919
echo Err
20+
echo SUCCESS
2021
exit 0
2122
EOF
2223
echo 1 >file &&
@@ -35,6 +36,7 @@ test_expect_success 'keywords' '
3536
grep "<BOLD;RED>error<RESET>: error" decoded &&
3637
grep "<YELLOW>hint<RESET>:" decoded &&
3738
grep "<BOLD;GREEN>success<RESET>:" decoded &&
39+
grep "<BOLD;GREEN>SUCCESS<RESET>" decoded &&
3840
grep "<BOLD;YELLOW>warning<RESET>:" decoded
3941
'
4042

0 commit comments

Comments
 (0)