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

Function pp_user_info

pretty.c:517–622  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

515}
516
517void pp_user_info(struct pretty_print_context *pp,
518 const char *what, struct strbuf *sb,
519 const char *line, const char *encoding)
520{
521 struct ident_split ident;
522 char *line_end;
523 const char *mailbuf, *namebuf;
524 size_t namelen, maillen;
525 int max_length = 78; /* per rfc2822 */
526
527 if (pp->fmt == CMIT_FMT_ONELINE)
528 return;
529
530 line_end = strchrnul(line, '\n');
531 if (split_ident_line(&ident, line, line_end - line))
532 return;
533
534 mailbuf = ident.mail_begin;
535 maillen = ident.mail_end - ident.mail_begin;
536 namebuf = ident.name_begin;
537 namelen = ident.name_end - ident.name_begin;
538
539 if (pp->mailmap)
540 map_user(pp->mailmap, &mailbuf, &maillen, &namebuf, &namelen);
541
542 if (cmit_fmt_is_mail(pp->fmt)) {
543 if (pp->from_ident && use_in_body_from(pp, &ident)) {
544 struct strbuf buf = STRBUF_INIT;
545
546 strbuf_addstr(&buf, "From: ");
547 strbuf_add(&buf, namebuf, namelen);
548 strbuf_addstr(&buf, " <");
549 strbuf_add(&buf, mailbuf, maillen);
550 strbuf_addstr(&buf, ">\n");
551 string_list_append(&pp->in_body_headers,
552 strbuf_detach(&buf, NULL));
553
554 mailbuf = pp->from_ident->mail_begin;
555 maillen = pp->from_ident->mail_end - mailbuf;
556 namebuf = pp->from_ident->name_begin;
557 namelen = pp->from_ident->name_end - namebuf;
558 }
559
560 strbuf_addstr(sb, "From: ");
561 if (pp->encode_email_headers &&
562 needs_rfc2047_encoding(namebuf, namelen)) {
563 add_rfc2047(sb, namebuf, namelen,
564 encoding, RFC2047_ADDRESS);
565 max_length = 76; /* per rfc2047 */
566 } else if (needs_rfc822_quoting(namebuf, namelen)) {
567 struct strbuf quoted = STRBUF_INIT;
568 add_rfc822_quoted(&quoted, namebuf, namelen);
569 strbuf_add_wrapped_bytes(sb, quoted.buf, quoted.len,
570 -6, 1, max_length);
571 strbuf_release(&quoted);
572 } else {
573 strbuf_add_wrapped_bytes(sb, namebuf, namelen,
574 -6, 1, max_length);

Callers 3

pp_headerFunction · 0.85
show_taggerFunction · 0.85
make_cover_letterFunction · 0.85

Calls 15

split_ident_lineFunction · 0.85
map_userFunction · 0.85
cmit_fmt_is_mailFunction · 0.85
use_in_body_fromFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_addFunction · 0.85
strbuf_detachFunction · 0.85
needs_rfc2047_encodingFunction · 0.85
add_rfc2047Function · 0.85
needs_rfc822_quotingFunction · 0.85
add_rfc822_quotedFunction · 0.85
strbuf_add_wrapped_bytesFunction · 0.85

Tested by

no test coverage detected