Merge branch 'jc/same-encoding'
authorJunio C Hamano <gitster@pobox.com>
Thu, 15 Nov 2012 18:24:05 +0000 (10:24 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 Nov 2012 18:24:05 +0000 (10:24 -0800)
Various codepaths checked if two encoding names are the same using
ad-hoc code and some of them ended up asking iconv() to convert
between "utf8" and "UTF-8".  The former is not a valid way to spell
the encoding name, but often people use it by mistake, and we
equated them in some but not all codepaths. Introduce a new helper
function to make these codepaths consistent.

* jc/same-encoding:
  reencode_string(): introduce and use same_encoding()

Conflicts:
builtin/mailinfo.c

1  2 
builtin/mailinfo.c
notes.c
pretty.c
sequencer.c
utf8.c

index da231400b327b86a18a054075f6aee4749846932,90b158d4f5c5b22a9493877dea6b08d568d637f9..24a772d8e1b7355a58088d784fdc18cd54302b7d
@@@ -481,9 -501,13 +481,10 @@@ static void convert_to_utf8(struct strb
  {
        char *out;
  
 -      if (!charset || !*charset) {
 -              charset = guess_charset(line, metainfo_charset);
 -              if (!charset)
 -                      return;
 -      }
 +      if (!charset || !*charset)
 +              return;
-       if (!strcasecmp(metainfo_charset, charset))
+       if (same_encoding(metainfo_charset, charset))
                return;
        out = reencode_string(line->buf, metainfo_charset, charset);
        if (!out)
diff --cc notes.c
Simple merge
diff --cc pretty.c
Simple merge
diff --cc sequencer.c
Simple merge
diff --cc utf8.c
Simple merge