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