Merge branch 'jk/add-ignore-errors-bit-assignment-fix'
[gitweb.git] / sideband.c
index e89d677626e278dc1e9f08ab239e8d203666e2d4..ef851113c44ee91e594734bf68567110b7ac8c6b 100644 (file)
@@ -86,7 +86,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
@@ -94,7 +94,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);
@@ -114,6 +115,7 @@ static void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)
 #define DUMB_SUFFIX "        "
 
 int demultiplex_sideband(const char *me, char *buf, int len,
+                        int die_on_error,
                         struct strbuf *scratch,
                         enum sideband_type *sideband_type)
 {
@@ -144,6 +146,8 @@ int demultiplex_sideband(const char *me, char *buf, int len,
        len--;
        switch (band) {
        case 3:
+               if (die_on_error)
+                       die("remote error: %s", buf + 1);
                strbuf_addf(scratch, "%s%s", scratch->len ? "\n" : "",
                            DISPLAY_PREFIX);
                maybe_colorize_sideband(scratch, buf + 1, len);
@@ -195,6 +199,8 @@ int demultiplex_sideband(const char *me, char *buf, int len,
        }
 
 cleanup:
+       if (die_on_error && *sideband_type == SIDEBAND_PROTOCOL_ERROR)
+               die("%s", scratch->buf);
        if (scratch->len) {
                strbuf_addch(scratch, '\n');
                xwrite(2, scratch->buf, scratch->len);