t: wrap complicated expect_code users in a block
[gitweb.git] / pretty.c
index a181ac66875a158514bba48a21911adf9c5cd8be..7b493041814dc8514bde0778497d39868c8455d7 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -567,7 +567,7 @@ static char *replace_encoding_header(char *buf, const char *encoding)
        char *cp = buf;
 
        /* guess if there is an encoding header before a \n\n */
-       while (strncmp(cp, "encoding ", strlen("encoding "))) {
+       while (!starts_with(cp, "encoding ")) {
                cp = strchr(cp, '\n');
                if (!cp || *++cp == '\n')
                        return buf;
@@ -964,9 +964,8 @@ static size_t parse_color(struct strbuf *sb, /* in UTF-8 */
                        if (!want_color(c->pretty_ctx->color))
                                return end - placeholder + 1;
                }
-               color_parse_mem(begin,
-                               end - begin,
-                               "--pretty format", color);
+               if (color_parse_mem(begin, end - begin, color) < 0)
+                       die(_("unable to parse --pretty format"));
                strbuf_addstr(sb, color);
                return end - placeholder + 1;
        }