pretty.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/pretty.c b/pretty.c index 0b40457f99f0..b9374a1708d1 100644 --- a/pretty.c +++ b/pretty.c @@ -1699,6 +1699,18 @@ static int pp_handle_indent(struct strbuf *sb, int indent, return 1; } +static void pp_add_line(struct pretty_print_context *pp, + struct strbuf *sb, int indent, + const char *line, int linelen) +{ + strbuf_grow(sb, linelen + indent + 20); + if (indent) { + if (pp_handle_indent(sb, indent, line, linelen)) + return; + } + strbuf_add(sb, line, linelen); +} + void pp_remainder(struct pretty_print_context *pp, const char **msg_p, struct strbuf *sb, @@ -1721,12 +1733,7 @@ void pp_remainder(struct pretty_print_context *pp, } first = 0; - strbuf_grow(sb, linelen + indent + 20); - if (indent) { - if (pp_handle_indent(sb, indent, line, linelen)) - linelen = 0; - } - strbuf_add(sb, line, linelen); + pp_add_line(pp, sb, indent, line, linelen); strbuf_addch(sb, '\n'); } }