Instead of dying in convert_to_utf8(), just report an error and let the callers handle it. Between the two callers: - decode_header() knows how to handle malformed line by reporting the breakage to the caller, so let it follow the pattern it already knows about; - handle_commit_msg() doesn't cope with a malformed line well, so die there for now. We'll lift this even higher in later changes in this series. Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> --- builtin/mailinfo.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index 6452a4c..f14c504 100644 --- a/builtin/mailinfo.c +++ b/builtin/mailinfo.c @@ -521,21 +521,22 @@ static struct strbuf *decode_b_segment(const struct strbuf *b_seg) return out; } -static void convert_to_utf8(struct mailinfo *mi, - struct strbuf *line, const char *charset) +static int convert_to_utf8(struct mailinfo *mi, + struct strbuf *line, const char *charset) { char *out; if (!mi->metainfo_charset || !charset || !*charset) - return; + return 0; if (same_encoding(mi->metainfo_charset, charset)) - return; + return 0; out = reencode_string(line->buf, mi->metainfo_charset, charset); if (!out) - die("cannot convert from %s to %s", - charset, mi->metainfo_charset); + return error("cannot convert from %s to %s", + charset, mi->metainfo_charset); strbuf_attach(line, out, strlen(out), strlen(out)); + return 0; } static int decode_header(struct mailinfo *mi, struct strbuf *it) @@ -602,7 +603,8 @@ static int decode_header(struct mailinfo *mi, struct strbuf *it) dec = decode_q_segment(&piecebuf, 1); break; } - convert_to_utf8(mi, dec, charset_q.buf); + if (convert_to_utf8(mi, dec, charset_q.buf)) + goto release_return; strbuf_addbuf(&outbuf, dec); strbuf_release(dec); @@ -778,7 +780,8 @@ static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line) mi->header_stage = 0; /* normalize the log message to UTF-8. */ - convert_to_utf8(mi, line, mi->charset.buf); + if (convert_to_utf8(mi, line, mi->charset.buf)) + exit(128); if (mi->use_scissors && is_scissors_line(line)) { int i; -- 2.6.1-320-g86a1181 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html