Re: Missing headers when forwarding html message as RFC822
[notmuch-archives.git] / 7b / a897ad5d788586a0a02fdfdd7ae11f8aaee6ac
1 Return-Path: <jani@nikula.org>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 0A17B431FAE\r
6         for <notmuch@notmuchmail.org>; Sun,  3 Mar 2013 13:55:21 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
9 X-Spam-Flag: NO\r
10 X-Spam-Score: -0.7\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
13         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id nZT72VodYyjM for <notmuch@notmuchmail.org>;\r
17         Sun,  3 Mar 2013 13:55:20 -0800 (PST)\r
18 Received: from mail-la0-f41.google.com (mail-la0-f41.google.com\r
19         [209.85.215.41]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 4A2EE431FBC\r
22         for <notmuch@notmuchmail.org>; Sun,  3 Mar 2013 13:55:20 -0800 (PST)\r
23 Received: by mail-la0-f41.google.com with SMTP id fo12so4440461lab.28\r
24         for <notmuch@notmuchmail.org>; Sun, 03 Mar 2013 13:55:18 -0800 (PST)\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=google.com; s=20120113;\r
27         h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
28         :references:in-reply-to:references:x-gm-message-state;\r
29         bh=wGaRPvaCRQlvxW/J5c/9raIR6+TSLjAW/ASXq6YhIGs=;\r
30         b=UZODMkm+nIiTl39U+4higi3rVQXoeQsNINxP9ATfR80argyOgHqlyA05ZiMXtEKTSi\r
31         PLu7NLi+C6usYILNz1QtmvfN/VXpkduDsxJfc5UGX4Ks50qOMEu1zbrJq4g0CaGqSLuZ\r
32         BiCIh+/zh5uex3zkhVFKOVRDlLmZptKzQyxOjZFiysLu1OT71RvfMo6HmBSqkkidWOA2\r
33         8cfjUNIDm4viyxhB572Kb6u23gUWEIT7csZs7dIiYoqlQBpAwNvosqolgOENha+Tkb15\r
34         S9daB3Had8Fw+yv5KSykMsjMO6CTefrNozK0pz1nKxA1/Vlk8iPm/oh5/AIFo3Azai2B\r
35         UyOg==\r
36 X-Received: by 10.152.125.239 with SMTP id mt15mr15873485lab.26.1362347718747;\r
37         Sun, 03 Mar 2013 13:55:18 -0800 (PST)\r
38 Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi.\r
39         [80.223.81.27])\r
40         by mx.google.com with ESMTPS id b13sm6611855lbd.10.2013.03.03.13.55.17\r
41         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
42         Sun, 03 Mar 2013 13:55:17 -0800 (PST)\r
43 From: Jani Nikula <jani@nikula.org>\r
44 To: notmuch@notmuchmail.org\r
45 Subject: [PATCH v2 2/6] cli: plug main notmuch command into subcommand\r
46         machinery\r
47 Date: Sun,  3 Mar 2013 23:55:06 +0200\r
48 Message-Id:\r
49  <bf81d217ceefc512a252a5acccd3c62b185eb874.1362347362.git.jani@nikula.org>\r
50 X-Mailer: git-send-email 1.7.10.4\r
51 In-Reply-To: <cover.1362347362.git.jani@nikula.org>\r
52 References: <cover.1362347362.git.jani@nikula.org>\r
53 In-Reply-To: <cover.1362347362.git.jani@nikula.org>\r
54 References: <cover.1362347362.git.jani@nikula.org>\r
55 X-Gm-Message-State:\r
56  ALoCoQmq3hzDQCOlvErbDQfgVMIA29Zu//QKRxYDVL0CdCdTCcUKgQFoeWrpZQAOxd6wC5ok2OoI\r
57 X-BeenThere: notmuch@notmuchmail.org\r
58 X-Mailman-Version: 2.1.13\r
59 Precedence: list\r
60 List-Id: "Use and development of the notmuch mail system."\r
61         <notmuch.notmuchmail.org>\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
63         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
65 List-Post: <mailto:notmuch@notmuchmail.org>\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
68         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
69 X-List-Received-Date: Sun, 03 Mar 2013 21:55:21 -0000\r
70 \r
71 This allows top level arguments to be added to notmuch in a way that\r
72 doesn't require special handling for the plain notmuch command without\r
73 a subcommand.\r
74 ---\r
75  notmuch.c |   26 +++++++++++++++++---------\r
76  1 file changed, 17 insertions(+), 9 deletions(-)\r
77 \r
78 diff --git a/notmuch.c b/notmuch.c\r
79 index 3dff6d4..ec2f20f 100644\r
80 --- a/notmuch.c\r
81 +++ b/notmuch.c\r
82 @@ -34,7 +34,13 @@ typedef struct command {\r
83  static int\r
84  notmuch_help_command (void *ctx, int argc, char *argv[]);\r
85  \r
86 +static int\r
87 +notmuch_command (void *ctx, int argc, char *argv[]);\r
88 +\r
89  static command_t commands[] = {\r
90 +    { NULL, notmuch_command,\r
91 +      NULL,\r
92 +      "Notmuch main command." },\r
93      { "setup", notmuch_setup_command,\r
94        NULL,\r
95        "Interactively setup notmuch for first use." },\r
96 @@ -76,7 +82,8 @@ find_command (const char *name)\r
97      size_t i;\r
98  \r
99      for (i = 0; i < ARRAY_SIZE (commands); i++)\r
100 -       if (strcmp (name, commands[i].name) == 0)\r
101 +       if ((!name && !commands[i].name) ||\r
102 +           (name && commands[i].name && strcmp (name, commands[i].name) == 0))\r
103             return &commands[i];\r
104  \r
105      return NULL;\r
106 @@ -101,8 +108,8 @@ usage (FILE *out)\r
107      for (i = 0; i < ARRAY_SIZE (commands); i++) {\r
108         command = &commands[i];\r
109  \r
110 -       fprintf (out, "  %-11s  %s\n",\r
111 -                command->name, command->summary);\r
112 +       if (command->name)\r
113 +           fprintf (out, "  %-11s  %s\n", command->name, command->summary);\r
114      }\r
115  \r
116      fprintf (out, "\n");\r
117 @@ -192,7 +199,7 @@ notmuch_help_command (void *ctx, int argc, char *argv[])\r
118   * to be more clever about this in the future.\r
119   */\r
120  static int\r
121 -notmuch (void *ctx)\r
122 +notmuch_command (void *ctx, unused(int argc), unused(char *argv[]))\r
123  {\r
124      notmuch_config_t *config;\r
125      notmuch_bool_t is_new;\r
126 @@ -256,6 +263,7 @@ main (int argc, char *argv[])\r
127  {\r
128      void *local;\r
129      char *talloc_report;\r
130 +    const char *command_name = NULL;\r
131      command_t *command;\r
132      notmuch_bool_t print_help=FALSE, print_version=FALSE;\r
133      int opt_index;\r
134 @@ -277,9 +285,6 @@ main (int argc, char *argv[])\r
135      /* Globally default to the current output format version. */\r
136      notmuch_format_version = NOTMUCH_FORMAT_CUR;\r
137  \r
138 -    if (argc == 1)\r
139 -       return notmuch (local);\r
140 -\r
141      opt_index = parse_arguments (argc, argv, options, 1);\r
142      if (opt_index < 0) {\r
143         /* diagnostics already printed */\r
144 @@ -294,10 +299,13 @@ main (int argc, char *argv[])\r
145         return 0;\r
146      }\r
147  \r
148 -    command = find_command (argv[opt_index]);\r
149 +    if (opt_index < argc)\r
150 +       command_name = argv[opt_index];\r
151 +\r
152 +    command = find_command (command_name);\r
153      if (!command) {\r
154         fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n",\r
155 -                argv[opt_index]);\r
156 +                command_name);\r
157         return 1;\r
158      }\r
159  \r
160 -- \r
161 1.7.10.4\r
162 \r