From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 0FBEF431FC7 for ; Tue, 24 Apr 2012 02:11:22 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.201 X-Spam-Level: X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=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 FTkrTM2E1fqG for ; Tue, 24 Apr 2012 02:11:20 -0700 (PDT) Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id E1CD5431FBC for ; Tue, 24 Apr 2012 02:11:11 -0700 (PDT) Received: by wgbdt14 with SMTP id dt14so309405wgb.2 for ; Tue, 24 Apr 2012 02:11:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=rTkrpXSzkWXjIeKq8SHqmWPWRwmnow/mW8LKZrpVgrM=; b=uPukufzSBzC5m4spiVitlcFx3aTIGJokvE3bwzVHp7+LqaOOqyWt/Is/34r3QmIXJB SRDTmHutkEw1loYkPf2PMjgxizRXFVogfzNHfHGMUyHCFuxH/cuKDl/Tc1o5KWijyYE0 6CPo+PzIjl2Nh7iUjf/Qi7nxLJf5jZ0cVcwsPQnXG6FzRLXKJv8+r0LfLCsm+12+g/Oj g4y+wIKgh8ZHQQPwnpH4Ksk/53a5oxuKlVnyaFTQsXqMAn5UINBRO9vFEo/1B27ISL6v FGH6XTOLQHQRdMnTS1HDqSlNAH7xWXakGwmQpOeAzvxiDPO3g8E3UudqdumTOViTtN0Q P/8Q== Received: by 10.180.107.101 with SMTP id hb5mr23305931wib.7.1335258669305; Tue, 24 Apr 2012 02:11:09 -0700 (PDT) Received: from localhost (94-192-233-223.zone6.bethere.co.uk. [94.192.233.223]) by mx.google.com with ESMTPS id ff2sm44875484wib.9.2012.04.24.02.11.07 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Apr 2012 02:11:07 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH v4 2/4] cli: make --entire-thread=false work for format=json. Date: Tue, 24 Apr 2012 10:11:13 +0100 Message-Id: <1335258675-29439-3-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1335258675-29439-1-git-send-email-markwalters1009@gmail.com> References: <1335258675-29439-1-git-send-email-markwalters1009@gmail.com> 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: Tue, 24 Apr 2012 09:11:22 -0000 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; @@ -1036,7 +1042,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) switch (format_sel) { case NOTMUCH_FORMAT_JSON: format = &format_json; - params.entire_thread = TRUE; + /* JSON defaults to entire-thread TRUE */ + if (params.entire_thread == -1) + params.entire_thread = TRUE; break; case NOTMUCH_FORMAT_TEXT: format = &format_text; @@ -1058,6 +1066,10 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) params.raw = TRUE; break; } + /* Default is entire-thread = FALSE except for format=json which + * is dealt with above. */ + if (params.entire_thread == -1) + params.entire_thread = FALSE; if (params.decrypt || verify) { #ifdef GMIME_ATLEAST_26 -- 1.7.9.1