show: Use consistent header ordering in the JSON format

Previously, top-level message headers were printed as Subject, From,
To, Date, while embedded message headers were printed From, To,
Subject, Date.  This makes both cases use the former order and updates
the tests accordingly.
This commit is contained in:
Austin Clements 2012-02-19 19:26:25 -05:00 committed by David Bremner
parent 44d9656cbf
commit 2209d7b952
2 changed files with 7 additions and 7 deletions

View file

@ -328,6 +328,9 @@ format_headers_message_part_json (GMimeMessage *message)
const char *recipients_string; const char *recipients_string;
printf ("%s: %s", printf ("%s: %s",
json_quote_str (ctx_quote, "Subject"),
json_quote_str (ctx_quote, g_mime_message_get_subject (message)));
printf (", %s: %s",
json_quote_str (ctx_quote, "From"), json_quote_str (ctx_quote, "From"),
json_quote_str (ctx_quote, g_mime_message_get_sender (message))); json_quote_str (ctx_quote, g_mime_message_get_sender (message)));
recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO); recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
@ -342,9 +345,6 @@ format_headers_message_part_json (GMimeMessage *message)
printf (", %s: %s", printf (", %s: %s",
json_quote_str (ctx_quote, "Cc"), json_quote_str (ctx_quote, "Cc"),
json_quote_str (ctx_quote, recipients_string)); json_quote_str (ctx_quote, recipients_string));
printf (", %s: %s",
json_quote_str (ctx_quote, "Subject"),
json_quote_str (ctx_quote, g_mime_message_get_subject (message)));
printf (", %s: %s", printf (", %s: %s",
json_quote_str (ctx_quote, "Date"), json_quote_str (ctx_quote, "Date"),
json_quote_str (ctx_quote, g_mime_message_get_date_as_string (message))); json_quote_str (ctx_quote, g_mime_message_get_date_as_string (message)));

View file

@ -325,7 +325,7 @@ cat <<EOF >EXPECTED
{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "filename": "${MAIL_DIR}/multipart", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Cc": "", "Bcc": "", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [ {"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "filename": "${MAIL_DIR}/multipart", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Cc": "", "Bcc": "", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [
{"id": 1, "content-type": "multipart/signed", "content": [ {"id": 1, "content-type": "multipart/signed", "content": [
{"id": 2, "content-type": "multipart/mixed", "content": [ {"id": 2, "content-type": "multipart/mixed", "content": [
{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
{"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 4, "content-type": "multipart/alternative", "content": [
{"id": 5, "content-type": "text/html"}, {"id": 5, "content-type": "text/html"},
{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
@ -342,7 +342,7 @@ cat <<EOF >EXPECTED
{"id": 1, "content-type": "multipart/signed", "content": [ {"id": 1, "content-type": "multipart/signed", "content": [
{"id": 2, "content-type": "multipart/mixed", "content": [ {"id": 2, "content-type": "multipart/mixed", "content": [
{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
{"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 4, "content-type": "multipart/alternative", "content": [
{"id": 5, "content-type": "text/html"}, {"id": 5, "content-type": "text/html"},
{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
@ -358,7 +358,7 @@ echo >>OUTPUT # expect *no* newline at end of output
cat <<EOF >EXPECTED cat <<EOF >EXPECTED
{"id": 2, "content-type": "multipart/mixed", "content": [ {"id": 2, "content-type": "multipart/mixed", "content": [
{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
{"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 4, "content-type": "multipart/alternative", "content": [
{"id": 5, "content-type": "text/html"}, {"id": 5, "content-type": "text/html"},
{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
@ -372,7 +372,7 @@ notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' | s
echo >>OUTPUT # expect *no* newline at end of output echo >>OUTPUT # expect *no* newline at end of output
cat <<EOF >EXPECTED cat <<EOF >EXPECTED
{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
{"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 4, "content-type": "multipart/alternative", "content": [
{"id": 5, "content-type": "text/html"}, {"id": 5, "content-type": "text/html"},
{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]} {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}