| 2296 | } |
| 2297 | |
| 2298 | void 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, " "); |
no test coverage detected