summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar René Scharfe <rene.scharfe@lsrfire.ath.cx>2013-04-25 21:41:57 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2013-04-25 15:02:53 -0700
commit97a17e7721dd026dbc4213608d4c61a9351ae527 (patch)
treeae6e636d3706de19bdcc4e95f47e813134f00ebc
parentpretty: simplify input line length calculation in pp_user_info() (diff)
downloadtgif-97a17e7721dd026dbc4213608d4c61a9351ae527.tar.xz
pretty: simplify output line length calculation in pp_user_info()
Keep namelen unchanged and don't use it to hold a value that we're not interested in anyway -- we can use maillen and the constant part directly instead. This simplifies the code slightly and prepares for the next patch that makes use of the original value of namelen. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--pretty.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/pretty.c b/pretty.c
index a9c35812dc..2031c77f15 100644
--- a/pretty.c
+++ b/pretty.c
@@ -439,8 +439,6 @@ void pp_user_info(const struct pretty_print_context *pp,
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)) {
@@ -457,9 +455,10 @@ void pp_user_info(const struct pretty_print_context *pp,
strbuf_add_wrapped_bytes(sb, name.buf, name.len,
-6, 1, max_length);
}
- if (namelen - name.len + last_line_length(sb) > max_length)
- strbuf_addch(sb, '\n');
+ if (max_length <
+ last_line_length(sb) + strlen(" <") + maillen + strlen(">"))
+ strbuf_addch(sb, '\n');
strbuf_addf(sb, " <%s>\n", mail.buf);
} else {
strbuf_addf(sb, "%s: %.*s%s <%s>\n", what,