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 <gitster@pobox.com>

Junio C Hamano committed Oct 18, 2015 at 15:58 UTC 28c6bfe94c83b810e5b23a2dc478c961c0534986
1 file changed +3 -5
builtin/mailinfo.c
+3 -5
@@ -384,7 +384,7 @@ static void convert_to_utf8(struct mailinfo *mi,
384 {
385 char *out;
386
387 - if (!charset || !*charset)
387 + if (!mi->metainfo_charset || !charset || !*charset)
388 return;
389
390 if (same_encoding(mi->metainfo_charset, charset))
@@ -459,8 +459,7 @@ static void decode_header(struct mailinfo *mi, struct strbuf *it)
459 dec = decode_q_segment(&piecebuf, 1);
460 break;
461 }
462 - if (mi->metainfo_charset)
463 - convert_to_utf8(mi, dec, charset_q.buf);
462 + convert_to_utf8(mi, dec, charset_q.buf);
463
464 strbuf_addbuf(&outbuf, dec);
465 strbuf_release(dec);
@@ -674,8 +673,7 @@ static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
673 mi->header_stage = 0;
674
675 /* 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);
677
678 if (mi->use_scissors && is_scissors_line(line)) {
679 int i;