Merge branch 'jc/maint-mailinfo-mime-attr'
authorJunio C Hamano <gitster@pobox.com>
Tue, 25 Sep 2012 17:39:56 +0000 (10:39 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 25 Sep 2012 17:39:56 +0000 (10:39 -0700)
When "git am" is fed an input that has multiple "Content-type: ..."
header, it did not grok charset= attribute correctly.

* jc/maint-mailinfo-mime-attr:
  mailinfo: do not concatenate charset= attribute values from mime headers

builtin/mailinfo.c
t/t5100-mailinfo.sh
t/t5100/info0017 [new file with mode: 0644]
t/t5100/msg0017 [new file with mode: 0644]
t/t5100/patch0017 [new file with mode: 0644]
t/t5100/sample.mbox

index b691b771587ac676b23c40f8d9090a3750eaa43f..2b3f4d955eaad6f7a020291b628588188974e388 100644 (file)
@@ -160,10 +160,9 @@ static int slurp_attr(const char *line, const char *name, struct strbuf *attr)
        const char *ends, *ap = strcasestr(line, name);
        size_t sz;
 
-       if (!ap) {
-               strbuf_setlen(attr, 0);
+       strbuf_setlen(attr, 0);
+       if (!ap)
                return 0;
-       }
        ap += strlen(name);
        if (*ap == '"') {
                ap++;
index 81904d9ec8d341399b534c5d576262439d0e1ad6..3e64a7a65da86410dd0236975bef9bd0013a6405 100755 (executable)
@@ -11,7 +11,7 @@ test_expect_success 'split sample box' \
        'git mailsplit -o. "$TEST_DIRECTORY"/t5100/sample.mbox >last &&
        last=`cat last` &&
        echo total is $last &&
-       test `cat last` = 16'
+       test `cat last` = 17'
 
 check_mailinfo () {
        mail=$1 opt=$2
diff --git a/t/t5100/info0017 b/t/t5100/info0017
new file mode 100644 (file)
index 0000000..d2bc89f
--- /dev/null
@@ -0,0 +1,5 @@
+Author: A U Thor
+Email: a.u.thor@example.com
+Subject: A E I O U
+Date: Mon, 17 Sep 2012 14:23:44 -0700
+
diff --git a/t/t5100/msg0017 b/t/t5100/msg0017
new file mode 100644 (file)
index 0000000..2ee0900
--- /dev/null
@@ -0,0 +1,2 @@
+New content here
+
diff --git a/t/t5100/patch0017 b/t/t5100/patch0017
new file mode 100644 (file)
index 0000000..35cf84c
--- /dev/null
@@ -0,0 +1,6 @@
+diff --git a/foo b/foo
+index e69de29..d95f3ad 100644
+--- a/foo
++++ b/foo
+@@ -0,0 +1 @@
++New content
index 34a09a0fc1c0ca9d1e68ed8bbf56e592c54e7227..8b2ae064c36b969ca20324154cea66bf26739de6 100644 (file)
@@ -683,3 +683,19 @@ index e69de29..d95f3ad 100644
 @@ -0,0 +1 @@
 +content
 
+From nobody Mon Sep 17 00:00:00 2001
+From: A U Thor <a.u.thor@example.com>
+Subject: A E I O U
+Date: Mon, 17 Sep 2012 14:23:44 -0700
+MIME-Version: 1.0
+Content-Type: text/plain; charset="iso-2022-jp"
+Content-type: text/plain; charset="UTF-8"
+
+New content here
+
+diff --git a/foo b/foo
+index e69de29..d95f3ad 100644
+--- a/foo
++++ b/foo
+@@ -0,0 +1 @@
++New content