Code

tag.h: Remove unused signature field
[git.git] / builtin-shortlog.c
index b98edc3ba6c155b632d5e140d0b5a3e8a2d4eb9b..ecd2d45a00b1aacf9d3a19e2f934a14ca7e58c35 100644 (file)
@@ -141,9 +141,9 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
        const char *author = NULL, *buffer;
        struct strbuf buf = STRBUF_INIT;
        struct strbuf ufbuf = STRBUF_INIT;
+       struct pretty_print_context ctx = {0};
 
-       pretty_print_commit(CMIT_FMT_RAW, commit, &buf,
-                           0, NULL, NULL, DATE_NORMAL, 0);
+       pretty_print_commit(CMIT_FMT_RAW, commit, &buf, &ctx);
        buffer = buf.buf;
        while (*buffer && *buffer != '\n') {
                const char *eol = strchr(buffer, '\n');
@@ -161,8 +161,12 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
                die("Missing author: %s",
                    sha1_to_hex(commit->object.sha1));
        if (log->user_format) {
-               pretty_print_commit(CMIT_FMT_USERFORMAT, commit, &ufbuf,
-                       DEFAULT_ABBREV, "", "", DATE_NORMAL, 0);
+               struct pretty_print_context ctx = {0};
+               ctx.abbrev = DEFAULT_ABBREV;
+               ctx.subject = "";
+               ctx.after_subject = "";
+               ctx.date_mode = DATE_NORMAL;
+               pretty_print_commit(CMIT_FMT_USERFORMAT, commit, &ufbuf, &ctx);
                buffer = ufbuf.buf;
        } else if (*buffer) {
                buffer++;
@@ -300,9 +304,19 @@ parse_done:
        return 0;
 }
 
+static void add_wrapped_shortlog_msg(struct strbuf *sb, const char *s,
+                                    const struct shortlog *log)
+{
+       int col = strbuf_add_wrapped_text(sb, s, log->in1, log->in2, log->wrap);
+       if (col != log->wrap)
+               strbuf_addch(sb, '\n');
+}
+
 void shortlog_output(struct shortlog *log)
 {
        int i, j;
+       struct strbuf sb = STRBUF_INIT;
+
        if (log->sort_by_number)
                qsort(log->list.items, log->list.nr, sizeof(struct string_list_item),
                        compare_by_number);
@@ -317,9 +331,9 @@ void shortlog_output(struct shortlog *log)
                                const char *msg = onelines->items[j].string;
 
                                if (log->wrap_lines) {
-                                       int col = print_wrapped_text(msg, log->in1, log->in2, log->wrap);
-                                       if (col != log->wrap)
-                                               putchar('\n');
+                                       strbuf_reset(&sb);
+                                       add_wrapped_shortlog_msg(&sb, msg, log);
+                                       fwrite(sb.buf, sb.len, 1, stdout);
                                }
                                else
                                        printf("      %s\n", msg);
@@ -333,6 +347,7 @@ void shortlog_output(struct shortlog *log)
                log->list.items[i].util = NULL;
        }
 
+       strbuf_release(&sb);
        log->list.strdup_strings = 1;
        string_list_clear(&log->list, 1);
        clear_mailmap(&log->mailmap);