Skip to content

Commit 28c6bfe

Browse files
committed
mailinfo: move check for metainfo_charset to convert_to_utf8()
All callers of this function refrain from calling it when mi->metainfo_charset is NULL; move the check to the callee, as it already has a few conditions at its beginning to turn it into a no-op. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 28be2d0 commit 28c6bfe

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

builtin/mailinfo.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ static void convert_to_utf8(struct mailinfo *mi,
384384
{
385385
char *out;
386386

387-
if (!charset || !*charset)
387+
if (!mi->metainfo_charset || !charset || !*charset)
388388
return;
389389

390390
if (same_encoding(mi->metainfo_charset, charset))
@@ -459,8 +459,7 @@ static void decode_header(struct mailinfo *mi, struct strbuf *it)
459459
dec = decode_q_segment(&piecebuf, 1);
460460
break;
461461
}
462-
if (mi->metainfo_charset)
463-
convert_to_utf8(mi, dec, charset_q.buf);
462+
convert_to_utf8(mi, dec, charset_q.buf);
464463

465464
strbuf_addbuf(&outbuf, dec);
466465
strbuf_release(dec);
@@ -674,8 +673,7 @@ static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
674673
mi->header_stage = 0;
675674

676675
/* normalize the log message to UTF-8. */
677-
if (mi->metainfo_charset)
678-
convert_to_utf8(mi, line, charset.buf);
676+
convert_to_utf8(mi, line, charset.buf);
679677

680678
if (mi->use_scissors && is_scissors_line(line)) {
681679
int i;

0 commit comments

Comments
 (0)