Re: [PATCH v4 2/4] cli: make --entire-thread=false work for format=json.
authorPeter Wang <novalazy@gmail.com>
Sat, 26 May 2012 02:15:56 +0000 (12:15 +1000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:25 +0000 (09:47 -0800)
92/8e3d44ff24c0a073366d31d44c71d7ba273132 [new file with mode: 0644]

diff --git a/92/8e3d44ff24c0a073366d31d44c71d7ba273132 b/92/8e3d44ff24c0a073366d31d44c71d7ba273132
new file mode 100644 (file)
index 0000000..4c46113
--- /dev/null
@@ -0,0 +1,108 @@
+Return-Path: <novalazy@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 082D8431FBC\r
+       for <notmuch@notmuchmail.org>; Fri, 25 May 2012 19:16:07 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id e4FbCdcX4E45 for <notmuch@notmuchmail.org>;\r
+       Fri, 25 May 2012 19:16:05 -0700 (PDT)\r
+Received: from mail-pz0-f53.google.com (mail-pz0-f53.google.com\r
+       [209.85.210.53]) (using TLSv1 with cipher RC4-MD5 (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id EE004431FB6\r
+       for <notmuch@notmuchmail.org>; Fri, 25 May 2012 19:16:04 -0700 (PDT)\r
+Received: by dadg9 with SMTP id g9so2352140dad.26\r
+       for <notmuch@notmuchmail.org>; Fri, 25 May 2012 19:16:04 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=date:message-id:from:to:subject:in-reply-to:references:mime-version\r
+       :content-type:content-disposition:content-transfer-encoding;\r
+       bh=78hP+B+HUESHDfPCYpxtVTZkUehqUgCJVI8HNPmg8+0=;\r
+       b=deCYmdt8SkchIo/0fwwv/xsxVQ45Gvny0cgLd1ydzz3TTl3q1UEQ7UXrrkv001Vewl\r
+       U5tFGIxobiqb0ZqPhlLdltSBNhxNKhebneC/QYYud8LKPd/TvdXwrz7Dcd8lBDRXYJo9\r
+       N0RXfU0rKCQ3U0xtBkrehc88de3RJSSoYXZSiwZtqCQh3iaSKS9jj6jjFl8zwL65nIFf\r
+       xZb9hIf95W3UY27z7lN70oOhalMx3AZiXgQYEscUhkOt6T6DjdXfJtkMsiKfzFUVJZ3k\r
+       PxdrC3oJa4Ef3mK+1stKC0O0Fjk846DXkGgncmp4N7xPuyz9Jxaz0B2zEWKeGuR0gRqJ\r
+       L8JQ==\r
+Received: by 10.68.191.106 with SMTP id gx10mr2703702pbc.161.1337998564074;\r
+       Fri, 25 May 2012 19:16:04 -0700 (PDT)\r
+Received: from localhost (215.42.233.220.static.exetel.com.au.\r
+       [220.233.42.215])\r
+       by mx.google.com with ESMTPS id in7sm10929125pbc.23.2012.05.25.19.16.00\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Fri, 25 May 2012 19:16:02 -0700 (PDT)\r
+Date: Sat, 26 May 2012 12:15:56 +1000\r
+Message-ID: <20120526121556.GA2328@hili.localdomain>\r
+From: Peter Wang <novalazy@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v4 2/4] cli: make --entire-thread=false work for\r
+       format=json.\r
+In-Reply-To: <1335258675-29439-3-git-send-email-markwalters1009@gmail.com>\r
+References: <1335258675-29439-1-git-send-email-markwalters1009@gmail.com>\r
+       <1335258675-29439-3-git-send-email-markwalters1009@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Disposition: inline\r
+Content-Transfer-Encoding: 8bit\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 26 May 2012 02:16:07 -0000\r
+\r
+On Tue, 24 Apr 2012 10:11:13 +0100, Mark Walters <markwalters1009@gmail.com> wrote:\r
+> The --entire-thread option in notmuch-show.c defaults to true when\r
+> format=json. Previously there was no way to turn this off. This patch\r
+> makes it respect --entire-thread=false.\r
+> \r
+> The one subtlety is that we initialise a notmuch_bool_t to -1 to\r
+> indicate that the option parsing has not set it. This allows the code\r
+> to distinguish between the option being omitted from the command line,\r
+> and the option being set to false on the command line.\r
+> ---\r
+>  notmuch-show.c |   16 ++++++++++++++--\r
+>  1 files changed, 14 insertions(+), 2 deletions(-)\r
+> \r
+> diff --git a/notmuch-show.c b/notmuch-show.c\r
+> index 0d21f1a..48551bb 100644\r
+> --- a/notmuch-show.c\r
+> +++ b/notmuch-show.c\r
+> @@ -996,7 +996,13 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+>      char *query_string;\r
+>      int opt_index, ret;\r
+>      const notmuch_show_format_t *format = &format_text;\r
+> -    notmuch_show_params_t params = { .part = -1, .omit_excluded = TRUE };\r
+> +\r
+> +    /* We abuse the notmuch_bool_t variable params.entire-thread by\r
+> +     * setting it to -1 to denote that the command line parsing has\r
+> +     * not set it. We ensure it is set to TRUE or FALSE before passing\r
+> +     * it to any other function.*/\r
+> +    notmuch_show_params_t params = { .part = -1, .entire_thread = -1 };\r
+> +\r
+>      int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;\r
+>      notmuch_bool_t verify = FALSE;\r
+>      int exclude = EXCLUDE_TRUE;\r
+\r
+Hi Mark,\r
+\r
+As an alternative to the abuse, could you just treat it as with exclude,\r
+using an enum with three values (TRUE|FALSE|DEFAULT)?\r
+Then set params.entire_thread afterwards.\r
+\r
+Peter\r