summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2012-09-07 11:08:38 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-09-07 11:08:38 -0700
commitae80b5a8928770a2b56c390d13bd3c48ebd2255f (patch)
treedef201c30c9130ef7df45337f8232e777160dcb0 /builtin
parentMerge branch 'pw/p4-use-client-spec-branch-detection' (diff)
parentcommit/commit-tree: correct latin1 to utf-8 (diff)
downloadtgif-ae80b5a8928770a2b56c390d13bd3c48ebd2255f.tar.xz
Merge branch 'lt/commit-tree-guess-utf-8'
Teach "git commit" and "git commit-tree" the "we are told to use utf-8 in log message, but this does not look like utf-8---attempt to pass it through convert-from-latin1-to-utf8 and see if it makes sense" heuristics "git mailinfo" already uses. * lt/commit-tree-guess-utf-8: commit/commit-tree: correct latin1 to utf-8
Diffstat (limited to 'builtin')
-rw-r--r--builtin/mailinfo.c28
1 files changed, 2 insertions, 26 deletions
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
index eaf9e157a3..dd4f925475 100644
--- a/builtin/mailinfo.c
+++ b/builtin/mailinfo.c
@@ -481,36 +481,12 @@ static struct strbuf *decode_b_segment(const struct strbuf *b_seg)
return out;
}
-/*
- * When there is no known charset, guess.
- *
- * Right now we assume that if the target is UTF-8 (the default),
- * and it already looks like UTF-8 (which includes US-ASCII as its
- * subset, of course) then that is what it is and there is nothing
- * to do.
- *
- * Otherwise, we default to assuming it is Latin1 for historical
- * reasons.
- */
-static const char *guess_charset(const struct strbuf *line, const char *target_charset)
-{
- if (is_encoding_utf8(target_charset)) {
- if (is_utf8(line->buf))
- return NULL;
- }
- return "ISO8859-1";
-}
-
static void convert_to_utf8(struct strbuf *line, const char *charset)
{
char *out;
- if (!charset || !*charset) {
- charset = guess_charset(line, metainfo_charset);
- if (!charset)
- return;
- }
-
+ if (!charset || !*charset)
+ return;
if (!strcasecmp(metainfo_charset, charset))
return;
out = reencode_string(line->buf, metainfo_charset, charset);