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

Function repo_format_commit_message

pretty.c:2000–2051  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1998}
1999
2000void repo_format_commit_message(struct repository *r,
2001 const struct commit *commit,
2002 const char *format, struct strbuf *sb,
2003 const struct pretty_print_context *pretty_ctx)
2004{
2005 struct format_commit_context context = {
2006 .repository = r,
2007 .commit = commit,
2008 .pretty_ctx = pretty_ctx,
2009 .wrap_start = sb->len
2010 };
2011 const char *output_enc = pretty_ctx->output_encoding;
2012 const char *utf8 = "UTF-8";
2013
2014 while (strbuf_expand_step(sb, &format)) {
2015 size_t len;
2016
2017 if (skip_prefix(format, "%", &format))
2018 strbuf_addch(sb, '%');
2019 else if ((len = format_commit_item(sb, format, &context)))
2020 format += len;
2021 else
2022 strbuf_addch(sb, '%');
2023 }
2024 rewrap_message_tail(sb, &context, 0, 0, 0);
2025
2026 /*
2027 * Convert output to an actual output encoding; note that
2028 * format_commit_item() will always use UTF-8, so we don't
2029 * have to bother if that's what the output wants.
2030 */
2031 if (output_enc) {
2032 if (same_encoding(utf8, output_enc))
2033 output_enc = NULL;
2034 } else {
2035 if (context.commit_encoding &&
2036 !same_encoding(context.commit_encoding, utf8))
2037 output_enc = context.commit_encoding;
2038 }
2039
2040 if (output_enc) {
2041 size_t outsz;
2042 char *out = reencode_string_len(sb->buf, sb->len,
2043 output_enc, utf8, &outsz);
2044 if (out)
2045 strbuf_attach(sb, out, outsz, outsz + 1);
2046 }
2047
2048 free(context.commit_encoding);
2049 repo_unuse_commit_buffer(r, commit, context.message);
2050 signature_check_clear(&context.signature_check);
2051}
2052
2053static void pp_header(struct pretty_print_context *pp,
2054 const char *encoding,

Callers 15

format_commitFunction · 0.85
shortlogFunction · 0.85
format_substFunction · 0.85
print_commit_summaryFunction · 0.85
refer_to_commitFunction · 0.85
pretty_print_commitFunction · 0.85
fmt_output_commitFunction · 0.85
do_remerge_diffFunction · 0.85
show_ambiguous_objectFunction · 0.85
bisect_checkoutFunction · 0.85

Calls 9

strbuf_expand_stepFunction · 0.85
strbuf_addchFunction · 0.85
format_commit_itemFunction · 0.85
rewrap_message_tailFunction · 0.85
same_encodingFunction · 0.85
strbuf_attachFunction · 0.85
repo_unuse_commit_bufferFunction · 0.85
signature_check_clearFunction · 0.85
reencode_string_lenFunction · 0.70

Tested by 1

print_commitFunction · 0.68