MCPcopy Index your code
hub / github.com/git/git / pp_header

Function pp_header

pretty.c:2053–2107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2051}
2052
2053static void pp_header(struct pretty_print_context *pp,
2054 const char *encoding,
2055 const struct commit *commit,
2056 const char **msg_p,
2057 struct strbuf *sb)
2058{
2059 int parents_shown = 0;
2060
2061 for (;;) {
2062 const char *name, *line = *msg_p;
2063 int linelen = get_one_line(*msg_p);
2064
2065 if (!linelen)
2066 return;
2067 *msg_p += linelen;
2068
2069 if (linelen == 1)
2070 /* End of header */
2071 return;
2072
2073 if (pp->fmt == CMIT_FMT_RAW) {
2074 strbuf_add(sb, line, linelen);
2075 continue;
2076 }
2077
2078 if (starts_with(line, "parent ")) {
2079 if (linelen != the_hash_algo->hexsz + 8)
2080 die("bad parent line in commit");
2081 continue;
2082 }
2083
2084 if (!parents_shown) {
2085 unsigned num = commit_list_count(commit->parents);
2086 /* with enough slop */
2087 strbuf_grow(sb, num * (GIT_MAX_HEXSZ + 10) + 20);
2088 add_merge_info(pp, sb, commit);
2089 parents_shown = 1;
2090 }
2091
2092 /*
2093 * MEDIUM == DEFAULT shows only author with dates.
2094 * FULL shows both authors but not dates.
2095 * FULLER shows both authors and dates.
2096 */
2097 if (skip_prefix(line, "author ", &name)) {
2098 strbuf_grow(sb, linelen + 80);
2099 pp_user_info(pp, "Author", sb, name, encoding);
2100 }
2101 if (skip_prefix(line, "committer ", &name) &&
2102 (pp->fmt == CMIT_FMT_FULL || pp->fmt == CMIT_FMT_FULLER)) {
2103 strbuf_grow(sb, linelen + 80);
2104 pp_user_info(pp, "Commit", sb, name, encoding);
2105 }
2106 }
2107}
2108
2109void pp_email_subject(struct pretty_print_context *pp,
2110 const char **msg_p,

Callers 1

pretty_print_commitFunction · 0.85

Calls 8

get_one_lineFunction · 0.85
strbuf_addFunction · 0.85
starts_withFunction · 0.85
commit_list_countFunction · 0.85
strbuf_growFunction · 0.85
add_merge_infoFunction · 0.85
pp_user_infoFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected