From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id EOXHH9naQGDqagAA0tVLHw (envelope-from ) for ; Thu, 04 Mar 2021 13:04:25 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id wDGJG9naQGAKcQAAbx9fmQ (envelope-from ) for ; Thu, 04 Mar 2021 13:04:25 +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)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B6AB116054 for ; Thu, 4 Mar 2021 14:04:24 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 40A0B27C63; Thu, 4 Mar 2021 08:02:35 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 7EFF127569 for ; Thu, 4 Mar 2021 08:02:07 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id 770BC5FA96; Thu, 4 Mar 2021 08:02:07 -0500 (EST) Received: (nullmailer pid 4047212 invoked by uid 1000); Thu, 04 Mar 2021 13:01:45 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 24/27] CLI/config: support set/get with split configuration Date: Thu, 4 Mar 2021 09:01:36 -0400 Message-Id: <20210304130139.4046183-25-david@tethera.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210304130139.4046183-1-david@tethera.net> References: <20210304130139.4046183-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: U4LIUWU3RXCIGMKYKINETKXXP4QHS4MG X-Message-ID-Hash: U4LIUWU3RXCIGMKYKINETKXXP4QHS4MG 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=1614863064; 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=MGANDaCAU4nZjdjP0DWEnSSn7UrruE4vrPDvUx66Mfk=; b=E/D2P7ap471UwbY0VAi1tcQ3NCHNyJGLQ2DgoCZITxHKq6l3HyPjBaiarwZ0INpoUGaogS ouqTGYQJxWRAOSUt0131ep6Pezy3MmzHvXu9knhEPnjF2xf2k+/LeRpMMHEfYfeVPqcmtd cQHKS42a5ZOrahv2oKsZ2h4jRJzO5v4HXBgog8zfNx7HoSAt9LW+2vIQ08JxMWEeqly8B+ e4f/k05aNc8U5U09BOXSBjGC1Zr9S7C8xrAPA7r/D9bnZQzcK1MP9X9Uw2hcx8+QkJktU8 mEcWCc4OtK6ZCIhviua5MhvBEfciMAW2R3Dvm1UUPX/HJzku8hhumk+t9dDp7A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1614863064; a=rsa-sha256; cv=none; b=ruUhSrhNLSOoLsbp/qBn030ZyiuA7+SC4Jm9KpkEL9TxzYxVgxRqQptgkD0fV3ew4zw2E5 v0LEkhbudx3f3bkcxxPGV/Q9d/eWkDO7MMHdrf/fWDgGxRyJDDelNLgN1ZDtUtGouwxsBQ vLrgvQuCR9RNI9MsJJ2D7XvkPR5YYor0QfmIf32Xf7V/lPNUR79v84CDrfNcwpKZklIFMj OkNL8kO0gek55pbKeSBqyy0z49SHnl9tBwx6MDg9rp6+IF78ijcFfyXx6r+ZofllLyF58J zCBCzRDQjz31WGq1cBVwmMfGCl1U6fKHW6GAAz+B3HdGrFiqyXg87zFtOyea5w== 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.80 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: B6AB116054 X-Spam-Score: -0.80 X-Migadu-Scanner: scn1.migadu.com X-TUID: SnWBFzP5nC+m The code change is tiny, and transient, but the tests will serve as regression tests the config file opening is moved into subcommands. --- 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 fa6b7eaa..b1dac8a7 100644 --- a/notmuch.c +++ b/notmuch.c @@ -443,7 +443,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 }, { } }; @@ -565,6 +565,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.1