From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id fRuEDV8RbWCdIAEAgWs5BA (envelope-from ) for ; Wed, 07 Apr 2021 03:56:47 +0200 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 +IeIBl8RbWCORgAAB5/wlQ (envelope-from ) for ; Wed, 07 Apr 2021 01:56:47 +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 740A214749 for ; Wed, 7 Apr 2021 03:56:46 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 5E65629065; Tue, 6 Apr 2021 21:56:08 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id A070227567 for ; Tue, 6 Apr 2021 21:55:45 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id 96ECF5FA96; Tue, 6 Apr 2021 21:55:45 -0400 (EDT) Received: (nullmailer pid 2964256 invoked by uid 1000); Wed, 07 Apr 2021 01:55:35 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 25/28] CLI/config: support set/get with split configuration Date: Tue, 6 Apr 2021 22:55:27 -0300 Message-Id: <20210407015530.2964017-26-david@tethera.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210407015530.2964017-1-david@tethera.net> References: <20210407015530.2964017-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: UUVFV4YS2KZYPL4NKZFGAD2T53JSVV2E X-Message-ID-Hash: UUVFV4YS2KZYPL4NKZFGAD2T53JSVV2E 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=1617760606; 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=UDhZt1KvlOQzzFDJ/iUBucjz+BZkwWv+1b9cgANxwQM=; b=Kc3E8S6AQW505xeYT/w334yhE/RGeSQYXySBAMdzFJ5qtfqXnL6jHNxgJVcpRTHBjhSM4w xwQZHA+BJKQvNQmqvvZGIYTrJGXf6Q45hajMhUrL5IjdFSfaT463A1telTdyeK+rJrXyo7 TIy4/1qN1jmoHY9Uy4TO/kTZug0oeKfLPn2pTZYGrkRTBPhLku2yxJZgmD+T5Db2EZkjOq Yd8qBl8vb1GPM0iZ7DIp3sjamnXOmio557VXnootKHNIbhwIzo+rvP1KQyGzOzPjDJ5SQp VWaYlXbeNOVJmigHJHa9erP3/LDCFjVUzlYDMR+t1qC3tUim0XsvdNPdpY8lVQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1617760606; a=rsa-sha256; cv=none; b=RcXGQ3kNP07BZu0JeKLb9h4yYF6XVUM3oaSq2Fo+3ruo2Hj0+WXSnsCXN+ULzyXvsTd3Sk 4akWsy9gS7mGn/HAFKY4YXgiRXWuJ07wvg4hWc/SEh+/2SJ1wMlcBQfspomMyb3krdNF0I tl7VfvUTpY647gz1AyVD8lqOBYgS5Xz+QNTaUrGlgbygNuvIoQOTN4wY5sqbdNEiGuOd07 pLTcZlCte+esxkn6F4qzZ7qcI5G955cXwx25RAgLPBPoOkHU6/bl5e5gUSc/c6jyoSaPFV 6EgZdg9gfaZysmageisNW2IUBWZ3D9gLAwHaZS8KsF3EQJcmOPqcUbFKnLGF4Q== 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.88 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: 740A214749 X-Spam-Score: -0.88 X-Migadu-Scanner: scn0.migadu.com X-TUID: rqno3jWU4Jfv There are two small code changes. The main one is to retrieve the possibly updated config file name found during the database opening call. The second change is to allow empty config file names, as a (currently broken) way of specifying that configuration should only be taken from the database. --- notmuch.c | 5 +++- test/T055-path-config.sh | 60 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/notmuch.c b/notmuch.c index bcb4b768..61663908 100644 --- a/notmuch.c +++ b/notmuch.c @@ -454,7 +454,7 @@ main (int argc, char *argv[]) int ret = EXIT_SUCCESS; notmuch_opt_desc_t options[] = { - { .opt_string = &config_file_name, .name = "config" }, + { .opt_string = &config_file_name, .name = "config", .allow_empty = TRUE }, { .opt_inherit = notmuch_shared_options }, { } }; @@ -581,6 +581,9 @@ main (int argc, char *argv[]) } if (command->mode & NOTMUCH_COMMAND_CONFIG_OPEN) { + if (! config_file_name) + config_file_name = notmuch_config_path (notmuch); + config = notmuch_config_open (notmuch, config_file_name, command->mode); if (! config) { ret = EXIT_FAILURE; diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh index 0a34e67f..535c41e9 100755 --- a/test/T055-path-config.sh +++ b/test/T055-path-config.sh @@ -215,7 +215,65 @@ EOF test_expect_equal_file EXPECTED OUTPUT - restore_config + test_begin_subtest "Set config value ($config)" + name=${RANDOM} + value=${RANDOM} + notmuch config set test${test_count}.${name} ${value} + output=$(notmuch config get test${test_count}.${name}) + notmuch config set test${test_count}.${name} + output2=$(notmuch config get test${test_count}.${name}) + test_expect_equal "${output}+${output2}" "${value}+" + + test_begin_subtest "Set config value in database ($config)" + name=${RANDOM} + value=${RANDOM} + notmuch config set --database test${test_count}.${name} ${value} + output=$(notmuch config get test${test_count}.${name}) + notmuch config set --database test${test_count}.${name} + output2=$(notmuch config get test${test_count}.${name}) + test_expect_equal "${output}+${output2}" "${value}+" + + test_begin_subtest "Config list ($config)" + notmuch config list | notmuch_dir_sanitize | sed -e "s/^database.backup_dir=.*$/database.backup_dir/" \ + -e "s/^database.hook_dir=.*$/database.hook_dir/" \ + -e "s/^database.path=.*$/database.path/" > OUTPUT + cat < EXPECTED +built_with.compact=true +built_with.field_processor=true +built_with.retry_lock=true +database.backup_dir +database.hook_dir +database.mail_root=MAIL_DIR +database.path +maildir.synchronize_flags=true +new.ignore= +new.tags=unread;inbox +search.exclude_tags= +user.name=Notmuch Test Suite +user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org +user.primary_email=test_suite@notmuchmail.org +EOF + test_expect_equal_file EXPECTED OUTPUT + + case $config in + XDG*) + test_begin_subtest "Set shadowed config value in database ($config)" + test_subtest_known_broken + name=${RANDOM} + value=${RANDOM} + key=test${test_count}.${name} + notmuch config set --database ${key} ${value} + notmuch config set ${key} shadow${value} + output=$(notmuch --config='' config get ${key}) + notmuch config set --database ${key} + output2=$(notmuch --config='' config get ${key}) + notmuch config set ${key} + test_expect_equal "${output}+${output2}" "${value}+" + ;; + esac + restore_config + rm -rf home/.local + rm -rf home/.config done test_done -- 2.30.2