From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 8OpPB+IcA2AXHwAA0tVLHw (envelope-from ) for ; Sat, 16 Jan 2021 17:05:38 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id kHsUA+IcA2BpQQAA1q6Kng (envelope-from ) for ; Sat, 16 Jan 2021 17:05:38 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C928F9404CE for ; Sat, 16 Jan 2021 17:05:37 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 1935F2BF7B; Sat, 16 Jan 2021 12:04:49 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id DC2252BF4D for ; Sat, 16 Jan 2021 12:04:28 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id C977F5FF47; Sat, 16 Jan 2021 12:04:28 -0500 (EST) Received: (nullmailer pid 842423 invoked by uid 1000); Sat, 16 Jan 2021 17:04:15 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 22/38] cli/tag: convert to new config framework. Date: Sat, 16 Jan 2021 13:03:50 -0400 Message-Id: <20210116170406.842014-23-david@tethera.net> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116170406.842014-1-david@tethera.net> References: <20210116170406.842014-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: EBXOUEQ7CDDALYUTKAIAM6S6PZRR6SZL X-Message-ID-Hash: EBXOUEQ7CDDALYUTKAIAM6S6PZRR6SZL 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 X-Migadu-Spam-Score: -1.08 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: C928F9404CE X-Spam-Score: -1.08 X-Migadu-Scanner: scn1.migadu.com X-TUID: 8oNGdcUm018U In addition to changing configuration access, change talloc context for allocation. --- notmuch-tag.c | 25 ++++++++++++++----------- notmuch.c | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/notmuch-tag.c b/notmuch-tag.c index 205f2733..464874b4 100644 --- a/notmuch-tag.c +++ b/notmuch-tag.c @@ -187,11 +187,10 @@ tag_file (void *ctx, notmuch_database_t *notmuch, tag_op_flag_t flags, } int -notmuch_tag_command (notmuch_config_t *config, unused(notmuch_database_t *notmuch), int argc, char *argv[]) +notmuch_tag_command (unused(notmuch_config_t *config), notmuch_database_t *notmuch, int argc, char *argv[]) { tag_op_list_t *tag_ops = NULL; char *query_string = NULL; - notmuch_database_t *notmuch; struct sigaction action; tag_op_flag_t tag_flags = TAG_FLAG_NONE; bool batch = false; @@ -200,6 +199,7 @@ notmuch_tag_command (notmuch_config_t *config, unused(notmuch_database_t *notmuc const char *input_file_name = NULL; int opt_index; int ret; + notmuch_bool_t synchronize_flags; /* Set up our handler for SIGINT */ memset (&action, 0, sizeof (struct sigaction)); @@ -240,13 +240,13 @@ notmuch_tag_command (notmuch_config_t *config, unused(notmuch_database_t *notmuc return EXIT_FAILURE; } } else { - tag_ops = tag_op_list_create (config); + tag_ops = tag_op_list_create (notmuch); if (tag_ops == NULL) { fprintf (stderr, "Out of memory.\n"); return EXIT_FAILURE; } - if (parse_tag_command_line (config, argc - opt_index, argv + opt_index, + if (parse_tag_command_line (notmuch, argc - opt_index, argv + opt_index, &query_string, tag_ops)) return EXIT_FAILURE; @@ -261,22 +261,25 @@ notmuch_tag_command (notmuch_config_t *config, unused(notmuch_database_t *notmuc } } - if (notmuch_database_open (notmuch_config_get_database_path (config), - NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much)) - return EXIT_FAILURE; - notmuch_exit_if_unmatched_db_uuid (notmuch); - if (notmuch_config_get_maildir_synchronize_flags (config)) + if (print_status_database ( + "notmuch restore", + notmuch, + notmuch_config_get_bool (notmuch, NOTMUCH_CONFIG_SYNC_MAILDIR_FLAGS, + &synchronize_flags))) + return EXIT_FAILURE; + + if (synchronize_flags) tag_flags |= TAG_FLAG_MAILDIR_SYNC; if (remove_all) tag_flags |= TAG_FLAG_REMOVE_ALL; if (batch) - ret = tag_file (config, notmuch, tag_flags, input); + ret = tag_file (notmuch, notmuch, tag_flags, input); else - ret = tag_query (config, notmuch, query_string, tag_ops, tag_flags); + ret = tag_query (notmuch, notmuch, query_string, tag_ops, tag_flags); notmuch_database_destroy (notmuch); diff --git a/notmuch.c b/notmuch.c index 16504fc5..913fd312 100644 --- a/notmuch.c +++ b/notmuch.c @@ -157,7 +157,7 @@ static command_t commands[] = { "Count messages matching the search terms." }, { "reply", notmuch_reply_command, NOTMUCH_COMMAND_DATABASE_EARLY, "Construct a reply template for a set of messages." }, - { "tag", notmuch_tag_command, NOTMUCH_COMMAND_CONFIG_OPEN, + { "tag", notmuch_tag_command, NOTMUCH_COMMAND_DATABASE_EARLY | NOTMUCH_COMMAND_DATABASE_WRITE, "Add/remove tags for all messages matching the search terms." }, { "dump", notmuch_dump_command, NOTMUCH_COMMAND_DATABASE_EARLY | NOTMUCH_COMMAND_DATABASE_WRITE, "Create a plain-text dump of the tags for each message." }, -- 2.29.2