static void pp_header(struct pretty_print_context *pp, const char *encoding, const struct commit *commit, const char **msg_p, struct strbuf *sb) { int parents_shown = 0; for (;;) { const char *line = *msg_p; int linelen = get_one_line(*msg_p); if (!linelen) return; *msg_p += linelen; if (linelen == 1) /* End of header */ return; if (pp->fmt == CMIT_FMT_RAW) { strbuf_add(sb, line, linelen); continue; } if (starts_with(line, "parent ")) { if (linelen != 48) die("bad parent line in commit"); continue; } if (!parents_shown) { struct commit_list *parent; int num; for (parent = commit->parents, num = 0; parent; parent = parent->next, num++) ; /* with enough slop */ strbuf_grow(sb, num * 50 + 20); add_merge_info(pp, sb, commit); parents_shown = 1; } /* * MEDIUM == DEFAULT shows only author with dates. * FULL shows both authors but not dates. * FULLER shows both authors and dates. */ if (starts_with(line, "author ")) { strbuf_grow(sb, linelen + 80); pp_user_info(pp, "Author", sb, line + 7, encoding); } if (starts_with(line, "committer ") && (pp->fmt == CMIT_FMT_FULL || pp->fmt == CMIT_FMT_FULLER)) { strbuf_grow(sb, linelen + 80); pp_user_info(pp, "Commit", sb, line + 10, encoding); } } }
static void pp_header(enum cmit_fmt fmt, int abbrev, enum date_mode dmode, const char *encoding, const struct commit *commit, const char **msg_p, struct strbuf *sb) { int parents_shown = 0; for (;;) { const char *line = *msg_p; int linelen = get_one_line(*msg_p); if (!linelen) return; *msg_p += linelen; if (linelen == 1) /* End of header */ return; if (fmt == CMIT_FMT_RAW) { strbuf_add(sb, line, linelen); continue; } if (!memcmp(line, "parent ", 7)) { if (linelen != 48) die("bad parent line in commit"); continue; } if (!parents_shown) { struct commit_list *parent; int num; for (parent = commit->parents, num = 0; parent; parent = parent->next, num++) ; /* with enough slop */ strbuf_grow(sb, num * 50 + 20); add_merge_info(fmt, sb, commit, abbrev); parents_shown = 1; } /* * MEDIUM == DEFAULT shows only author with dates. * FULL shows both authors but not dates. * FULLER shows both authors and dates. */ if (!memcmp(line, "author ", 7)) { strbuf_grow(sb, linelen + 80); pp_user_info("Author", fmt, sb, line + 7, dmode, encoding); } if (!memcmp(line, "committer ", 10) && (fmt == CMIT_FMT_FULL || fmt == CMIT_FMT_FULLER)) { strbuf_grow(sb, linelen + 80); pp_user_info("Commit", fmt, sb, line + 10, dmode, encoding); } } }