From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: git discussion list <git@vger.kernel.org>
Cc: Antoine Pelisse <apelisse@gmail.com>, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 2/3] pretty: simplify output line length calculation in pp_user_info()
Date: Thu, 25 Apr 2013 21:41:57 +0200 [thread overview]
Message-ID: <51798705.7030108@lsrfire.ath.cx> (raw)
In-Reply-To: <517986A9.4060506@lsrfire.ath.cx>
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>
---
pretty.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/pretty.c b/pretty.c
index e51c993..6861997 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,
--
1.8.2.1
next prev parent reply other threads:[~2013-04-25 19:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-25 19:40 [PATCH 1/3] pretty: simplify input line length calculation in pp_user_info() René Scharfe
2013-04-25 19:41 ` René Scharfe [this message]
2013-04-25 19:43 ` [PATCH 3/3] pretty: remove intermediate strbufs from pp_user_info() René Scharfe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51798705.7030108@lsrfire.ath.cx \
--to=rene.scharfe@lsrfire.ath.cx \
--cc=apelisse@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.