pretty.c: use original commit message if reencoding fails

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Oct 23, 2011 at 22:51 UTC 1d5bd615c0d8dadfa9dee0511b3ba3feaf838877
1 file changed +4 -1
pretty.c
+4 -1
@@ -1022,8 +1022,11 @@ void format_commit_message(const struct commit *commit,
1022 context.message = commit->buffer;
1023 if (output_enc) {
1024 char *enc = get_header(commit, "encoding");
1025 - if (strcmp(enc ? enc : utf8, output_enc))
1025 + if (strcmp(enc ? enc : utf8, output_enc)) {
1026 context.message = logmsg_reencode(commit, output_enc);
1027 + if (!context.message)
1028 + context.message = commit->buffer;
1029 + }
1030 free(enc);
1031 }
1032