return show_date(date, tz, mode);
}
-void pp_user_info(const struct pretty_print_context *pp,
+void pp_user_info(struct pretty_print_context *pp,
const char *what, struct strbuf *sb,
const char *line, const char *encoding)
{
- struct strbuf name;
- struct strbuf mail;
struct ident_split ident;
- int linelen;
char *line_end;
const char *mailbuf, *namebuf;
size_t namelen, maillen;
if (pp->fmt == CMIT_FMT_ONELINE)
return;
- line_end = strchr(line, '\n');
- if (!line_end) {
- line_end = strchr(line, '\0');
- if (!line_end)
- return;
- }
-
- linelen = ++line_end - line;
- if (split_ident_line(&ident, line, linelen))
+ line_end = strchrnul(line, '\n');
+ if (split_ident_line(&ident, line, line_end - line))
return;
-
mailbuf = ident.mail_begin;
maillen = ident.mail_end - ident.mail_begin;
namebuf = ident.name_begin;
if (pp->mailmap)
map_user(pp->mailmap, &mailbuf, &maillen, &namebuf, &namelen);
- strbuf_init(&mail, 0);
- strbuf_init(&name, 0);
-
- strbuf_add(&mail, mailbuf, maillen);
- strbuf_add(&name, namebuf, namelen);
-
- namelen = name.len + mail.len + 3; /* ' ' + '<' + '>' */
-
if (pp->fmt == CMIT_FMT_EMAIL) {
strbuf_addstr(sb, "From: ");
- if (needs_rfc2047_encoding(name.buf, name.len, RFC2047_ADDRESS)) {
- add_rfc2047(sb, name.buf, name.len,
+ if (needs_rfc2047_encoding(namebuf, namelen, RFC2047_ADDRESS)) {
+ add_rfc2047(sb, namebuf, namelen,
encoding, RFC2047_ADDRESS);
max_length = 76; /* per rfc2047 */
- } else if (needs_rfc822_quoting(name.buf, name.len)) {
+ } else if (needs_rfc822_quoting(namebuf, namelen)) {
struct strbuf quoted = STRBUF_INIT;
- add_rfc822_quoted("ed, name.buf, name.len);
+ add_rfc822_quoted("ed, namebuf, namelen);
strbuf_add_wrapped_bytes(sb, quoted.buf, quoted.len,
-6, 1, max_length);
strbuf_release("ed);
} else {
- strbuf_add_wrapped_bytes(sb, name.buf, name.len,
+ strbuf_add_wrapped_bytes(sb, namebuf, namelen,
-6, 1, max_length);
}
- if (namelen - name.len + last_line_length(sb) > max_length)
- strbuf_addch(sb, '\n');
- strbuf_addf(sb, " <%s>\n", mail.buf);
+ if (max_length <
+ last_line_length(sb) + strlen(" <") + maillen + strlen(">"))
+ strbuf_addch(sb, '\n');
+ strbuf_addf(sb, " <%.*s>\n", (int)maillen, mailbuf);
} else {
- strbuf_addf(sb, "%s: %.*s%s <%s>\n", what,
- (pp->fmt == CMIT_FMT_FULLER) ? 4 : 0,
- " ", name.buf, mail.buf);
+ strbuf_addf(sb, "%s: %.*s%.*s <%.*s>\n", what,
+ (pp->fmt == CMIT_FMT_FULLER) ? 4 : 0, " ",
+ (int)namelen, namebuf, (int)maillen, mailbuf);
}
- strbuf_release(&mail);
- strbuf_release(&name);
-
switch (pp->fmt) {
case CMIT_FMT_MEDIUM:
strbuf_addf(sb, "Date: %s\n",
free(context.signature_check.signer);
}
-static void pp_header(const struct pretty_print_context *pp,
+static void pp_header(struct pretty_print_context *pp,
const char *encoding,
const struct commit *commit,
const char **msg_p,
}
}
-void pp_title_line(const struct pretty_print_context *pp,
+void pp_title_line(struct pretty_print_context *pp,
const char **msg_p,
struct strbuf *sb,
const char *encoding,
strbuf_release(&title);
}
-void pp_remainder(const struct pretty_print_context *pp,
+void pp_remainder(struct pretty_print_context *pp,
const char **msg_p,
struct strbuf *sb,
int indent)
}
}
-void pretty_print_commit(const struct pretty_print_context *pp,
+void pretty_print_commit(struct pretty_print_context *pp,
const struct commit *commit,
struct strbuf *sb)
{