[PATCH v2 05/14] cli/reply: reorganize create_reply_message()
[notmuch-archives.git] / 24 / 2d1ba79f9bfe4ef78ca6b1843c13802e8b6e02
1 Return-Path: <markwalters1009@gmail.com>\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 1D8DB431FD7\r
6         for <notmuch@notmuchmail.org>; Sat, 10 Mar 2012 03:05:46 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id u0wU1xfo7pZ4 for <notmuch@notmuchmail.org>;\r
18         Sat, 10 Mar 2012 03:05:44 -0800 (PST)\r
19 Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com\r
20         [209.85.212.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id 81BBA431FC3\r
23         for <notmuch@notmuchmail.org>; Sat, 10 Mar 2012 03:05:44 -0800 (PST)\r
24 Received: by mail-wi0-f173.google.com with SMTP id hq7so1254475wib.2\r
25         for <notmuch@notmuchmail.org>; Sat, 10 Mar 2012 03:05:44 -0800 (PST)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
28         bh=FhgNL4/V/BFx/Md6F0MTKs47nXWsS7Cqog/jtk6bWEE=;\r
29         b=ZY+ueJXLc5wnRjWp0od3f/b4iM1CyiO1MkLX6oqcWys+g1JqkUDhJIOd9bFQuIZ536\r
30         eK2D3pr8aKrMe8lCtj+qmC6w2t+kAxY3v24tXRK4y+l/ehNF7JT5svYhsi3e3c4o470q\r
31         jzF4qeNxe7mdUh2k8xZRdSj+YjSYb0Y0DmrgY1GA5yK6Z7L9+ACKcxdga5+SoHJkny3h\r
32         WbMjQTI1iFoyAUGY0fVhuPTLwsb+tKBaVaicA9SvozGfrGbWrQDn7b/rpMnlYmeLP6G/\r
33         xyj5Pj9STsbMWzyPm1ZcB8sJpG82Ln7JlrfDZJq1wKeBh3dhjJWzYskFHZtGR3NphgbR\r
34         GH9w==\r
35 Received: by 10.216.136.202 with SMTP id w52mr3372097wei.109.1331377544116;\r
36         Sat, 10 Mar 2012 03:05:44 -0800 (PST)\r
37 Received: from localhost (94-192-233-223.zone6.bethere.co.uk.\r
38  [94.192.233.223])      by mx.google.com with ESMTPS id\r
39  ep17sm13375140wid.2.2012.03.10.03.05.42        (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Sat, 10 Mar 2012 03:05:43 -0800 (PST)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH 2/2] cli: make --entire-thread=false work for format=json.\r
44 Date: Sat, 10 Mar 2012 11:05:33 +0000\r
45 Message-Id: <1331377533-30262-3-git-send-email-markwalters1009@gmail.com>\r
46 X-Mailer: git-send-email 1.7.9.1\r
47 In-Reply-To: <1331377533-30262-1-git-send-email-markwalters1009@gmail.com>\r
48 References: <1331377533-30262-1-git-send-email-markwalters1009@gmail.com>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Sat, 10 Mar 2012 11:05:46 -0000\r
62 \r
63 The --entire-thread option in notmuch-show.c defaults to true when\r
64 format=json. Previously there was no way to turn this off. This patch\r
65 makes it respect --entire-thread=false.\r
66 \r
67 The one subtlety is that we initialise a notmuch_bool_t to -1 to\r
68 indicate that the option parsing has not set it. This allows the code\r
69 to distinguish between the option being omitted from the command line,\r
70 and the option being set to false on the command line.\r
71 ---\r
72  notmuch-show.c |   15 +++++++++++++--\r
73  1 files changed, 13 insertions(+), 2 deletions(-)\r
74 \r
75 diff --git a/notmuch-show.c b/notmuch-show.c\r
76 index 05d51b2..8da1845 100644\r
77 --- a/notmuch-show.c\r
78 +++ b/notmuch-show.c\r
79 @@ -983,7 +983,12 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
80      char *query_string;\r
81      int opt_index, ret;\r
82      const notmuch_show_format_t *format = &format_text;\r
83 -    notmuch_show_params_t params = { .part = -1 };\r
84 +\r
85 +    /* We abuse the notmuch_bool_t variable params.entire-thread by\r
86 +     * setting it to -1 to denote that the command line parsing has\r
87 +     * not set it. We ensure it is set to TRUE or FALSE before passing\r
88 +     * it to any other function.*/\r
89 +    notmuch_show_params_t params = { .part = -1, .entire_thread = -1 };\r
90      int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;\r
91      notmuch_bool_t verify = FALSE;\r
92      notmuch_bool_t no_exclude = FALSE;\r
93 @@ -1020,7 +1025,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
94      switch (format_sel) {\r
95      case NOTMUCH_FORMAT_JSON:\r
96         format = &format_json;\r
97 -       params.entire_thread = TRUE;\r
98 +       /* JSON defaults to entire-thread TRUE */\r
99 +       if (params.entire_thread == -1)\r
100 +           params.entire_thread = TRUE;\r
101         break;\r
102      case NOTMUCH_FORMAT_TEXT:\r
103         format = &format_text;\r
104 @@ -1042,6 +1049,10 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
105         params.raw = TRUE;\r
106         break;\r
107      }\r
108 +    /* Default is entire-thread = FALSE except for format=json which\r
109 +     * is dealt with above. */\r
110 +    if (params.entire_thread == -1)\r
111 +       params.entire_thread = FALSE;\r
112  \r
113      if (params.decrypt || verify) {\r
114  #ifdef GMIME_ATLEAST_26\r
115 -- \r
116 1.7.9.1\r
117 \r