Skip to content

Commit 97a17e7

Browse files
René Scharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 30e77bc commit 97a17e7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pretty.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,6 @@ void pp_user_info(const struct pretty_print_context *pp,
439439
strbuf_add(&mail, mailbuf, maillen);
440440
strbuf_add(&name, namebuf, namelen);
441441

442-
namelen = name.len + mail.len + 3; /* ' ' + '<' + '>' */
443-
444442
if (pp->fmt == CMIT_FMT_EMAIL) {
445443
strbuf_addstr(sb, "From: ");
446444
if (needs_rfc2047_encoding(name.buf, name.len, RFC2047_ADDRESS)) {
@@ -457,9 +455,10 @@ void pp_user_info(const struct pretty_print_context *pp,
457455
strbuf_add_wrapped_bytes(sb, name.buf, name.len,
458456
-6, 1, max_length);
459457
}
460-
if (namelen - name.len + last_line_length(sb) > max_length)
461-
strbuf_addch(sb, '\n');
462458

459+
if (max_length <
460+
last_line_length(sb) + strlen(" <") + maillen + strlen(">"))
461+
strbuf_addch(sb, '\n');
463462
strbuf_addf(sb, " <%s>\n", mail.buf);
464463
} else {
465464
strbuf_addf(sb, "%s: %.*s%s <%s>\n", what,

0 commit comments

Comments
 (0)