Merge branch 'js/t3404-grammo-fix' into maint
[gitweb.git] / pretty.c
index c3ec430220a5667685dbdeca5252df48bd65cd41..b27165603ad953cb4bb0436566dc73fb374c3333 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -507,7 +507,7 @@ void pp_user_info(struct pretty_print_context *pp,
        }
 }
 
-static int is_empty_line(const char *line, int *len_p)
+static int is_blank_line(const char *line, int *len_p)
 {
        int len = *len_p;
        while (len && isspace(line[len - 1]))
@@ -516,14 +516,14 @@ static int is_empty_line(const char *line, int *len_p)
        return !len;
 }
 
-static const char *skip_empty_lines(const char *msg)
+const char *skip_blank_lines(const char *msg)
 {
        for (;;) {
                int linelen = get_one_line(msg);
                int ll = linelen;
                if (!linelen)
                        break;
-               if (!is_empty_line(msg, &ll))
+               if (!is_blank_line(msg, &ll))
                        break;
                msg += linelen;
        }
@@ -875,7 +875,7 @@ const char *format_subject(struct strbuf *sb, const char *msg,
                int linelen = get_one_line(line);
 
                msg += linelen;
-               if (!linelen || is_empty_line(line, &linelen))
+               if (!linelen || is_blank_line(line, &linelen))
                        break;
 
                if (!sb)
@@ -894,11 +894,11 @@ static void parse_commit_message(struct format_commit_context *c)
        const char *msg = c->message + c->message_off;
        const char *start = c->message;
 
-       msg = skip_empty_lines(msg);
+       msg = skip_blank_lines(msg);
        c->subject_off = msg - start;
 
        msg = format_subject(NULL, msg, NULL);
-       msg = skip_empty_lines(msg);
+       msg = skip_blank_lines(msg);
        c->body_off = msg - start;
 
        c->commit_message_parsed = 1;
@@ -1022,9 +1022,15 @@ static size_t parse_padding_placeholder(struct strbuf *sb,
                int width;
                if (!end || end == start)
                        return 0;
-               width = strtoul(start, &next, 10);
+               width = strtol(start, &next, 10);
                if (next == start || width == 0)
                        return 0;
+               if (width < 0) {
+                       if (to_column)
+                               width += term_columns();
+                       if (width < 0)
+                               return 0;
+               }
                c->padding = to_column ? -width : width;
                c->flush_type = flush_type;
 
@@ -1299,6 +1305,7 @@ static size_t format_and_pad_commit(struct strbuf *sb, /* in UTF-8 */
                if (!start)
                        start = sb->buf;
                occupied = utf8_strnwidth(start, -1, 1);
+               occupied += c->pretty_ctx->graph_width;
                padding = (-padding) - occupied;
        }
        while (1) {
@@ -1711,7 +1718,7 @@ void pp_remainder(struct pretty_print_context *pp,
                if (!linelen)
                        break;
 
-               if (is_empty_line(line, &linelen)) {
+               if (is_blank_line(line, &linelen)) {
                        if (first)
                                continue;
                        if (pp->fmt == CMIT_FMT_SHORT)
@@ -1782,7 +1789,7 @@ void pretty_print_commit(struct pretty_print_context *pp,
        }
 
        /* Skip excess blank lines at the beginning of body, if any... */
-       msg = skip_empty_lines(msg);
+       msg = skip_blank_lines(msg);
 
        /* These formats treat the title line specially. */
        if (pp->fmt == CMIT_FMT_ONELINE || pp->fmt == CMIT_FMT_EMAIL)