Merge branch 'jc/mailinfo-RE'
authorJunio C Hamano <gitster@pobox.com>
Sat, 15 Sep 2012 04:39:27 +0000 (21:39 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 15 Sep 2012 04:39:27 +0000 (21:39 -0700)
We strip the prefix from "Re: subject" and also from a less common
"re: subject", but left even less common "RE: subject" intact.

* jc/mailinfo-RE:
mailinfo: strip "RE: " prefix

1  2 
builtin/mailinfo.c
diff --combined builtin/mailinfo.c
index dd4f925475fd2012822575a86e78dcd24c1ef8ef,18895ee4d9c987ec97d6781a5ffe5ec935bf19c7..b691b771587ac676b23c40f8d9090a3750eaa43f
@@@ -232,7 -232,9 +232,9 @@@ static void cleanup_subject(struct strb
                case 'r': case 'R':
                        if (subject->len <= at + 3)
                                break;
-                       if (!memcmp(subject->buf + at + 1, "e:", 2)) {
+                       if ((subject->buf[at + 1] == 'e' ||
+                            subject->buf[at + 1] == 'E') &&
+                           subject->buf[at + 2] == ':') {
                                strbuf_remove(subject, at, 3);
                                continue;
                        }
@@@ -481,12 -483,36 +483,12 @@@ static struct strbuf *decode_b_segment(
        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);