unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: Ian <saturns_rings@protonmail.com>,
	"notmuch@notmuchmail.org" <notmuch@notmuchmail.org>
Subject: [PATCH 2/2] CLI/setup: special case single item lists
Date: Mon, 17 Jan 2022 19:54:53 -0400	[thread overview]
Message-ID: <20220117235453.2735624-2-david@tethera.net> (raw)
In-Reply-To: <20220117235453.2735624-1-david@tethera.net>

This matches the heuristic used by "notmuch config set" to decide if
something is a list.

This change fixes the bug reported at [1].

[1]: id:6O3LTUhoXlrnkPWCtPJCP4cagU7mFVEdyTpcC_37BoSzStlARXDBa7oczy6hB0jyjGjBQvgj_jFV58cw0aNx-jUg1h1O-FQ7820k68C0X4M=@protonmail.com
---
 notmuch-config.c                                | 5 ++++-
 test/T040-setup.sh                              | 1 -
 test/setup.expected-output/config-with-comments | 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/notmuch-config.c b/notmuch-config.c
index 11d8d68b..e9456d79 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -383,7 +383,10 @@ _config_set_list (notmuch_conffile_t *config,
 		  const char *list[],
 		  size_t length)
 {
-    g_key_file_set_string_list (config->key_file, group, key, list, length);
+    if (length > 1)
+	g_key_file_set_string_list (config->key_file, group, key, list, length);
+    else
+	g_key_file_set_string (config->key_file, group, key, list[0]);
 }
 
 void
diff --git a/test/T040-setup.sh b/test/T040-setup.sh
index 36a42562..10b29ec3 100755
--- a/test/T040-setup.sh
+++ b/test/T040-setup.sh
@@ -24,7 +24,6 @@ expected_dir=$NOTMUCH_SRCDIR/test/setup.expected-output
 test_expect_equal_file ${expected_dir}/config-with-comments new-notmuch-config
 
 test_begin_subtest "setup consistent with config-set for single items"
-test_subtest_known_broken
 # note this relies on the config state from the previous test.
 notmuch --config=new-notmuch-config config list > list.setup
 notmuch --config=new-notmuch-config config set search.exclude_tags baz
diff --git a/test/setup.expected-output/config-with-comments b/test/setup.expected-output/config-with-comments
index 56c628e5..d8397714 100644
--- a/test/setup.expected-output/config-with-comments
+++ b/test/setup.expected-output/config-with-comments
@@ -31,7 +31,7 @@ path=/path/to/maildir
 [user]
 name=Test Suite
 primary_email=test.suite@example.com
-other_email=another.suite@example.com;
+other_email=another.suite@example.com
 
 # Configuration for "notmuch new"
 #
@@ -60,7 +60,7 @@ tags=foo;bar;
 #		query will override that exclusion.
 #
 [search]
-exclude_tags=baz;
+exclude_tags=baz
 
 # Maildir compatibility configuration
 #
-- 
2.34.1

  reply	other threads:[~2022-01-17 23:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-14 21:17 [BUG] Minor: config list adds a semi-colon to lists with a single item until set Ian
2017-11-18 20:13 ` David Bremner
2022-01-17 23:54 ` [PATCH 1/2] test/setup: add known broken test for single items David Bremner
2022-01-17 23:54   ` David Bremner [this message]
2022-01-24 13:35     ` [PATCH 2/2] CLI/setup: special case single item lists David Bremner
2022-01-24 13:37 ` [BUG] Minor: config list adds a semi-colon to lists with a single item until set David Bremner
2022-03-31  9:14   ` Ian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220117235453.2735624-2-david@tethera.net \
    --to=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    --cc=saturns_rings@protonmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).