From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id RlhDBB0NRWD8ZQAA0tVLHw (envelope-from ) for ; Sun, 07 Mar 2021 17:27:57 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id KPtuOxwNRWAMVQAAB5/wlQ (envelope-from ) for ; Sun, 07 Mar 2021 17:27:56 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7DBA91497D for ; Sun, 7 Mar 2021 18:27:56 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id F10B227583; Sun, 7 Mar 2021 12:27:44 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 1CC8226BB1 for ; Sun, 7 Mar 2021 12:27:41 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id 1478E5FA96; Sun, 7 Mar 2021 12:27:41 -0500 (EST) Received: (nullmailer pid 1091641 invoked by uid 1000); Sun, 07 Mar 2021 17:27:38 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 05/22] CLI/show: complete conversion to new configuration framework. Date: Sun, 7 Mar 2021 13:27:17 -0400 Message-Id: <20210307172734.1091264-6-david@tethera.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210307172734.1091264-1-david@tethera.net> References: <20210307172734.1091264-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: FOIYWDY6PJXBPN5SFFPREEN6OZFYY3Q4 X-Message-ID-Hash: FOIYWDY6PJXBPN5SFFPREEN6OZFYY3Q4 X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1615138076; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Yg4QU2ZXOCvwfsD7EGnG0MojJIK7N9ye/jnk0aIZCEg=; b=MNKG74HXrA2prrb8dbAM9Pc2gZh4QknsmOybe5Ai8zAAMQufLDiFblk42Ib2PxytW+Zdsc KswScm0Y8I9FvJgkKaKjK9/xauJdNWmo1UVd8rk7b4aQb7Mf1IfNQYYwcWOGCK7Ooi/uS8 /FRvLklqpwqlfqPIfzPdxxPySg0ZTTScNoxmZ5pek/BgMv7OHHM7eLCa61f8jsHPT/dqOL cKJD7GFMuZKGunM8Nj8cDRTH/y6A4SkyMUgd5lRMsAXjPc6rxpQOcujYzoxogvlliLP2gR p3kvqEB2j/xZpOrHtUGrmaCVuifO/kkvZnupK0E2kdtK7NB3/Qlw9c14y4HsUQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1615138076; a=rsa-sha256; cv=none; b=AUsKv123hMHjm7bLzLrnYYrWksTPZsXAHIfikaQx/XcaRMpatskeD2nhelNEcQiHAUVXbw 1uvbYda742XFt9sPYk49YZFgR/ZofkA4EO2IV5UaweDYnTalAVo77N8ZxpmBD8qN66ySWt F3rpjmlT6JZAgsY6NAQx7aAeK2n91hK8y8irN2s0HEP3iEehV47VnEVt+AfUZfw7DrUBLl BVjCH3ONaH6BdvIMFoKDpvmGS/pkE1SeH2I9DKdxPqAhTT9rAabz7xqO3HMOpBO+WrLiY8 KMWbl6hQltQBNnNG1Fkjm6Aq950ZSzece/CfNWkMpLihiZLSW8M91ogH2hpo2w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -0.96 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 7DBA91497D X-Spam-Score: -0.96 X-Migadu-Scanner: scn1.migadu.com X-TUID: sLw5guQKRLVP In order to open the database in main() for this command, we may need to re-open it in the (possibly less common) case where crypto options require it. --- notmuch-show.c | 27 +++++++-------------------- notmuch.c | 2 +- test/T035-read-config.sh | 2 -- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index 2c474682..ce8b9915 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -1218,9 +1218,8 @@ static const notmuch_show_format_t *formatters[] = { }; int -notmuch_show_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[]) +notmuch_show_command (unused (notmuch_config_t *config), notmuch_database_t *notmuch, int argc, char *argv[]) { - notmuch_database_t *notmuch; notmuch_query_t *query; char *query_string; int opt_index, ret; @@ -1237,7 +1236,7 @@ notmuch_show_command (notmuch_config_t *config, unused(notmuch_database_t *notmu bool entire_thread_set = false; bool single_message; bool unthreaded = FALSE; - char *status_string = NULL; + notmuch_status_t status; notmuch_opt_desc_t options[] = { { .opt_keyword = &format, .name = "format", .keywords = @@ -1327,26 +1326,14 @@ notmuch_show_command (notmuch_config_t *config, unused(notmuch_database_t *notmu fprintf (stderr, "Warning: --include-html only implemented for format=text, format=json and format=sexp\n"); } - notmuch_database_mode_t mode = NOTMUCH_DATABASE_MODE_READ_ONLY; - - if (params.crypto.decrypt == NOTMUCH_DECRYPT_TRUE) - mode = NOTMUCH_DATABASE_MODE_READ_WRITE; - if (notmuch_database_open_with_config (NULL, - mode, - _notmuch_config_get_path (config), - NULL, - ¬much, - &status_string)) { - if (status_string) { - fputs (status_string, stderr); - free (status_string); + if (params.crypto.decrypt == NOTMUCH_DECRYPT_TRUE) { + status = notmuch_database_reopen (notmuch, NOTMUCH_DATABASE_MODE_READ_WRITE); + if (status) { + fprintf (stderr, "Error reopening database for READ_WRITE: %s\n", notmuch_status_to_string (status)); + return EXIT_FAILURE; } - - return EXIT_FAILURE; } - config = NULL; - notmuch_exit_if_unmatched_db_uuid (notmuch); query_string = query_string_from_args (notmuch, argc - opt_index, argv + opt_index); diff --git a/notmuch.c b/notmuch.c index 7360e0e6..71482e43 100644 --- a/notmuch.c +++ b/notmuch.c @@ -152,7 +152,7 @@ static command_t commands[] = { "Search for messages matching the given search terms." }, { "address", notmuch_address_command, NOTMUCH_COMMAND_DATABASE_EARLY, "Get addresses from messages matching the given search terms." }, - { "show", notmuch_show_command, NOTMUCH_COMMAND_CONFIG_OPEN, + { "show", notmuch_show_command, NOTMUCH_COMMAND_DATABASE_EARLY, "Show all messages matching the search terms." }, { "count", notmuch_count_command, NOTMUCH_COMMAND_DATABASE_EARLY, "Count messages matching the search terms." }, diff --git a/test/T035-read-config.sh b/test/T035-read-config.sh index 205d1736..ac0f420b 100755 --- a/test/T035-read-config.sh +++ b/test/T035-read-config.sh @@ -378,7 +378,6 @@ restore_database test_expect_equal "$output" "OK" test_begin_subtest "show with alternate config (xdg)" -test_subtest_known_broken backup_database notmuch tag -- +foobar17 '*' xdg_config @@ -389,7 +388,6 @@ restore_config test_expect_equal "$output" "OK" test_begin_subtest "show with alternate config (xdg+profile)" -test_subtest_known_broken backup_database notmuch tag -- +foobar17 '*' xdg_config foobar17 -- 2.30.1