[PATCH 02/18] test: convert random-corpus to use n_d_open_with_config

2021-02-20 Thread David Bremner
Remove one more usage of notmuch_config_get_database_path --- test/random-corpus.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/random-corpus.c b/test/random-corpus.c index ff413252..67e106e0 100644 --- a/test/random-corpus.c +++ b/test/random-corpus.c @@

[PATCH 18/18] WIP: CLI/config: make storing configuration in database optional

2021-02-20 Thread David Bremner
Originally I planned to drop this functionality, but it is useful e.g. for our test suite to be able to set config keys in the database without using notmuch-restore. New option needs documentation --- notmuch-config.c | 26 ++ test/T030-config.sh| 19

[PATCH 03/18] lib/open: pull _load_key_file out of _choose_database_path

2021-02-20 Thread David Bremner
Although this increases code duplication, it also increases flexibility in handling various combinations of missing config file and missing database. --- lib/open.cc | 36 +++- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/lib/open.cc

[PATCH 06/18] lib/config: add config_pairs iterators

2021-02-20 Thread David Bremner
The layer of shims here seems a bit wasteful compared to just calling the corresponding string map functions directly, but it allows control over the API (calling with notmuch_database_t *) and flexibility for future changes. --- lib/config.cc | 39 ++

[PATCH 05/18] WIP: add n_d_get_config_values

2021-02-20 Thread David Bremner
--- lib/config.cc | 14 ++ lib/notmuch.h | 2 ++ test/T590-libconfig.sh | 23 +++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/lib/config.cc b/lib/config.cc index 32ed6f8f..47e8bf82 100644 --- a/lib/config.cc +++

[PATCH 04/18] WIP: add notmuch_database_load_config

2021-02-20 Thread David Bremner
This needs at least documentation and probably more tests. --- lib/notmuch.h | 9 ++ lib/open.cc| 96 ++ test/T590-libconfig.sh | 182 - 3 files changed, 284 insertions(+), 3 deletions(-) diff --git

[PATCH 07/18] lib/config: set defaults for user full name

2021-02-20 Thread David Bremner
This just copies code from from the CLI into the library. New test infrastructure is needed because apparently we have never tested this code path. --- lib/config.cc | 48 +- test/T590-libconfig.sh | 13 test/test-lib.sh | 7

[PATCH 16/18] cli/config: drop obsolete notmuch_config_get_*

2021-02-20 Thread David Bremner
These are no longer used, replaced by notmuch_config_get. --- notmuch-client.h | 29 notmuch-config.c | 119 --- 2 files changed, 148 deletions(-) diff --git a/notmuch-client.h b/notmuch-client.h index dfdfc876..677f2f39 100644 ---

[PATCH 09/18] CLI/notmuch: replace use of notmuch_config_get_*

2021-02-20 Thread David Bremner
The notmuch_config_get_{field_name} internal API will be removed in a subsequent commit. --- notmuch.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/notmuch.c b/notmuch.c index 71482e43..a161f127 100644 --- a/notmuch.c +++ b/notmuch.c @@ -364,7 +364,7 @@

[PATCH 17/18] CLI/config: drop cached data from notmuch_config_t

2021-02-20 Thread David Bremner
The idea is to preserve notmuch_config_t as a thin wrapper for GKeyFile. --- notmuch-config.c | 48 +--- 1 file changed, 9 insertions(+), 39 deletions(-) diff --git a/notmuch-config.c b/notmuch-config.c index 1382b0a3..0b2976f4 100644 ---

[PATCH 12/18] WIP: switch notmuch-setup to new configuration framework

2021-02-20 Thread David Bremner
--- notmuch-setup.c | 55 +++-- notmuch.c | 19 ++--- 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/notmuch-setup.c b/notmuch-setup.c index 67214470..1e22412b 100644 --- a/notmuch-setup.c +++ b/notmuch-setup.c @@

[PATCH 14/18] CLI/config: migrate notmuch_config_open to new config

2021-02-20 Thread David Bremner
notmuch_config_open will be preserved in the medium term for use by the commands that are manipulating the config file directly (config and setup) --- lib/config.cc | 5 +- notmuch-client.h | 2 +- notmuch-config.c | 157 +

[PATCH 13/18] WIP: CLI/config: switch list to new config

2021-02-20 Thread David Bremner
Test output changes because keys are now listed in alphabetical order, and because a missing database is no longer an error. --- notmuch-config.c| 69 - test/T030-config.sh | 27 -- test/T040-setup.sh | 27 +++--- 3

[PATCH 10/18] CLI/config: WIP: load merged config

2021-02-20 Thread David Bremner
--- notmuch-client.h | 1 + notmuch.c | 29 ++--- test/T030-config.sh| 11 +++ test/T590-libconfig.sh | 3 --- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/notmuch-client.h b/notmuch-client.h index f60f5406..db88daf8

[PATCH 11/18] WIP: CLI/config: use merged config for "config get"

2021-02-20 Thread David Bremner
--- notmuch-config.c| 92 + test/T030-config.sh | 20 +- 2 files changed, 28 insertions(+), 84 deletions(-) diff --git a/notmuch-config.c b/notmuch-config.c index 0193401f..a4613227 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@

[PATCH 08/18] lib/config: set default for primary user email

2021-02-20 Thread David Bremner
This is mainly copying code from the CLI into the lib. The CLI copy will be deleted in a later commit. --- lib/config.cc | 70 +++--- test/T590-libconfig.sh | 4 +-- test/test-lib.sh | 6 +++- 3 files changed, 73 insertions(+), 7 deletions(-)

RFC convert remaining CLI to new configuration

2021-02-20 Thread David Bremner
This is an early version of a series to convert the remaining CLI (config, setup, and notmuch_command) to the new configuration framework. There are a few design decisions / compromomises that people might have opinions about. - The merged config API uses a notmuch_data_t as the primary

[PATCH 01/18] lib: add missing status strings

2021-02-20 Thread David Bremner
--- lib/database.cc | 8 1 file changed, 8 insertions(+) diff --git a/lib/database.cc b/lib/database.cc index ffd42ac4..87ad1385 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -292,12 +292,20 @@ notmuch_status_to_string (notmuch_status_t status) return "Operation requires

[PATCH 15/18] WIP: cli/config: convert to new config API

2021-02-20 Thread David Bremner
--- notmuch-config.c | 16 +++- test/T750-user-header.sh | 3 ++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/notmuch-config.c b/notmuch-config.c index 3d0959fb..390998b1 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -725,9 +725,8 @@