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

Function pretty_print_commit

pretty.c:2298–2378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2296}
2297
2298void pretty_print_commit(struct pretty_print_context *pp,
2299 const struct commit *commit,
2300 struct strbuf *sb)
2301{
2302 unsigned long beginning_of_body;
2303 int indent = 4;
2304 const char *msg;
2305 const char *reencoded;
2306 const char *encoding;
2307 int need_8bit_cte = pp->need_8bit_cte;
2308
2309 if (pp->fmt == CMIT_FMT_USERFORMAT) {
2310 repo_format_commit_message(the_repository, commit,
2311 user_format, sb, pp);
2312 return;
2313 }
2314
2315 encoding = get_log_output_encoding();
2316 msg = reencoded = repo_logmsg_reencode(the_repository, commit, NULL,
2317 encoding);
2318
2319 if (pp->fmt == CMIT_FMT_ONELINE || cmit_fmt_is_mail(pp->fmt))
2320 indent = 0;
2321
2322 /*
2323 * We need to check and emit Content-type: to mark it
2324 * as 8-bit if we haven't done so.
2325 */
2326 if (cmit_fmt_is_mail(pp->fmt) && need_8bit_cte == 0) {
2327 int i, ch, in_body;
2328
2329 for (in_body = i = 0; (ch = msg[i]); i++) {
2330 if (!in_body) {
2331 /* author could be non 7-bit ASCII but
2332 * the log may be so; skip over the
2333 * header part first.
2334 */
2335 if (ch == '\n' && msg[i+1] == '\n')
2336 in_body = 1;
2337 }
2338 else if (non_ascii(ch)) {
2339 need_8bit_cte = 1;
2340 break;
2341 }
2342 }
2343 }
2344
2345 pp_header(pp, encoding, commit, &msg, sb);
2346 if (pp->fmt != CMIT_FMT_ONELINE && !cmit_fmt_is_mail(pp->fmt)) {
2347 strbuf_addch(sb, '\n');
2348 }
2349
2350 /* Skip excess blank lines at the beginning of body, if any... */
2351 msg = skip_blank_lines(msg);
2352
2353 /* These formats treat the title line specially. */
2354 if (pp->fmt == CMIT_FMT_ONELINE) {
2355 msg = format_subject(sb, msg, " ");

Callers 9

make_script_with_mergesFunction · 0.85
sequencer_make_scriptFunction · 0.85
pp_commit_easyFunction · 0.85
show_logFunction · 0.85
get_format_revFunction · 0.85
squash_messageFunction · 0.85
show_commitFunction · 0.85
shortlog_add_commitFunction · 0.85

Calls 13

get_log_output_encodingFunction · 0.85
repo_logmsg_reencodeFunction · 0.85
cmit_fmt_is_mailFunction · 0.85
non_asciiFunction · 0.85
pp_headerFunction · 0.85
strbuf_addchFunction · 0.85
skip_blank_linesFunction · 0.85
format_subjectFunction · 0.85
pp_email_subjectFunction · 0.85
pp_remainderFunction · 0.85
strbuf_rtrimFunction · 0.85

Tested by

no test coverage detected