notmuch
6 days agoCLI: rename notmuch_config_t to notmuch_conffile_t master next
David Bremner [Sat, 27 Feb 2021 14:11:23 +0000 (10:11 -0400)]
CLI: rename notmuch_config_t to notmuch_conffile_t

The name is a compromise between keeping function names from getting
too long, and avoiding confusion with the newer notmuch_config library
API. Try to make clear that the residual functionality is only about
updating configuration files.

6 days agoCLI: drop notmuch_config_t from subcommand interface.
David Bremner [Sat, 27 Feb 2021 14:07:45 +0000 (10:07 -0400)]
CLI: drop notmuch_config_t from subcommand interface.

At this point it is unused in all subcommands.

6 days agoCLI/config: remove calls to notmuch_config_open from top level
David Bremner [Sat, 27 Feb 2021 13:22:32 +0000 (09:22 -0400)]
CLI/config: remove calls to notmuch_config_open from top level

This will allow simplifying the subcommand interface.

Change the internal API to notmuch_config_open to not tie it to the
implementation of subcommands in notmuch.c.

It also fixes a previously broken test, since notmuch_config_open does
not understand the notion of the empty string as a config file name.

2 weeks agoCLI/config: support set/get with split configuration
David Bremner [Thu, 25 Feb 2021 12:00:26 +0000 (08:00 -0400)]
CLI/config: support set/get with split configuration

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.

2 weeks agolib: provide notmuch_config_path
David Bremner [Sun, 21 Feb 2021 11:34:52 +0000 (07:34 -0400)]
lib: provide notmuch_config_path

Since the library searches in several locations for a config file, the
caller does not know which of these is chosen in the usual case of
passing NULL as a config file. This changes provides an API for the
caller to retrieve the name of the config file chosen. It will be
tested in a following commit.

2 weeks agoCLI+lib: detect missing database in split configurations.
David Bremner [Tue, 23 Feb 2021 20:19:13 +0000 (16:19 -0400)]
CLI+lib: detect missing database in split configurations.

Eventually we want to do all opening of databases in the top
level (main function). This means that detection of missing databases
needs to move out of subcommands. It also requires updating the
library to use the new NO_DATABASE status code.

2 weeks agolib: add NOTMUCH_STATUS_NO_DATABASE
David Bremner [Tue, 23 Feb 2021 19:56:47 +0000 (15:56 -0400)]
lib: add NOTMUCH_STATUS_NO_DATABASE

This will allow more precise return values from various open related functions.

2 weeks agoCLI/config: default to storing all config in external files
David Bremner [Fri, 19 Feb 2021 12:41:36 +0000 (08:41 -0400)]
CLI/config: default to storing all config in external files

Previously the fact that some configuration options were only stored
in the database (and thus editing the config file had no effect) was a
source of user confusion. This was fixed with the series ending at
d9af0af1646.

On the other hand, the underlying partition of config options into
those stored by default in the database and those stored in the config
file remained. This is also confusing, since now some invocations of
"notmuch config set" modify the config file, and others silently
modify the database instead.

With this commit, it is up to the user to decide which configuration
to modify. A new "--database" option is provided for notmuch config to
enable modifying the configuration information in the database;
otherwise the default is to update an external config file.

2 weeks agoCLI/config: drop cached data from notmuch_config_t
David Bremner [Sun, 14 Feb 2021 18:36:18 +0000 (14:36 -0400)]
CLI/config: drop cached data from notmuch_config_t

The idea is to preserve notmuch_config_t as a thin wrapper for GKeyFile.

2 weeks agoCLI/config: drop obsolete notmuch_config_get_*
David Bremner [Sun, 14 Feb 2021 18:02:51 +0000 (14:02 -0400)]
CLI/config: drop obsolete notmuch_config_get_*

These are no longer used, replaced by notmuch_config_get.

2 weeks agoCLI/notmuch: switch notmuch_command to notmuch_config_get
David Bremner [Tue, 23 Feb 2021 13:22:37 +0000 (09:22 -0400)]
CLI/notmuch: switch notmuch_command to notmuch_config_get

The goal at this point is to remove the dependence on
notmuch_config_get_* without breaking any existing functionality. This
is a step towards removing notmuch_config_get_* in a future commit.

2 weeks agoCLI/config: use notmuch_database_reopen
David Bremner [Sun, 14 Feb 2021 17:46:13 +0000 (13:46 -0400)]
CLI/config: use notmuch_database_reopen

This allows `notmuch config` to use the common configuration
information carried by the notmuch_database_t opened at the top level.

2 weeks agoCLI/config: migrate notmuch_config_open to new config
David Bremner [Sun, 14 Feb 2021 13:32:41 +0000 (09:32 -0400)]
CLI/config: migrate notmuch_config_open to new config

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)

2 weeks agoCLI/config: switch "notmuch config list" to merged config
David Bremner [Sun, 14 Feb 2021 11:54:22 +0000 (07:54 -0400)]
CLI/config: switch "notmuch config list" to merged config

Use the database opened at the top level rather than opening another
notmuch_database_t.

Test output changes because keys are now listed in alphabetical order,
and because a missing database is no longer an error.

2 weeks agoCLI/setup: switch to new configuration framework
David Bremner [Sat, 13 Feb 2021 17:49:32 +0000 (13:49 -0400)]
CLI/setup: switch to new configuration framework

Most of the changes are the elimination of notmuch_config_t accessor
use. We also migrate some of the diagnostics to the top level where we
are opening the files in question.

2 weeks agotest/setup: check file output instead of notmuch config list
David Bremner [Sat, 27 Feb 2021 14:50:33 +0000 (10:50 -0400)]
test/setup: check file output instead of notmuch config list

This allows verification of comments added to new / updated config
file.

2 weeks agoCLI/config: use merged config for "config get"
David Bremner [Sat, 13 Feb 2021 13:01:50 +0000 (09:01 -0400)]
CLI/config: use merged config for "config get"

This commit starts the conversion of notmuch-config.c
functionality (as opposed to just interface) to the new config
framework.

The change to T030-config is because of the move of the
canonicalization database paths from the notmuch_config_t accessor to
the internal function _choose_database_path.

2 weeks agoCLI: load merged config at top level
David Bremner [Wed, 10 Feb 2021 00:26:40 +0000 (20:26 -0400)]
CLI: load merged config at top level

This paves the way for the conversion of the remaining subcommands to
the new configuration framework.

2 weeks agolib/open: canonicalize relative path read from config file
David Bremner [Wed, 3 Mar 2021 12:31:44 +0000 (08:31 -0400)]
lib/open: canonicalize relative path read from config file

This matches functionality in the the CLI function
notmuch_config_get_database_path, which was previously used in the CLI
code for all calls to open a database.

2 weeks agolib/config: set default for primary user email
David Bremner [Sun, 14 Feb 2021 13:55:42 +0000 (09:55 -0400)]
lib/config: set default for primary user email

This is mainly copying code from the CLI into the lib. The CLI copy
will be deleted in a later commit.

2 weeks agolib/config: set defaults for user full name
David Bremner [Sun, 14 Feb 2021 13:23:44 +0000 (09:23 -0400)]
lib/config: set defaults for user full name

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.

2 weeks agolib/config: add config_pairs iterators
David Bremner [Sun, 14 Feb 2021 11:42:58 +0000 (07:42 -0400)]
lib/config: add config_pairs iterators

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.

2 weeks agolib/config: add notmuch_config_get_values_string
David Bremner [Sat, 13 Feb 2021 17:17:52 +0000 (13:17 -0400)]
lib/config: add notmuch_config_get_values_string

This is to support the less common (at least in the notmuch codebase)
case of accessing a ;-delimited list config value with an arbitrary
string key.

2 weeks agolib: provide notmuch_database_load_config
David Bremner [Tue, 9 Feb 2021 23:48:38 +0000 (19:48 -0400)]
lib: provide notmuch_database_load_config

This is mainly targetted at notmuch-config.c, or similar applications
that don't necessarily need both a configuration file and a database
to exist.

2 weeks agolib/open: pull _load_key_file out of _choose_database_path
David Bremner [Thu, 11 Feb 2021 00:02:37 +0000 (20:02 -0400)]
lib/open: pull _load_key_file out of _choose_database_path

Although this increases code duplication, it also increases
flexibility in handling various combinations of missing config file
and missing database.

2 weeks agotest: convert random-corpus to use n_d_open_with_config
David Bremner [Sun, 14 Feb 2021 17:54:37 +0000 (13:54 -0400)]
test: convert random-corpus to use n_d_open_with_config

Remove one more usage of notmuch_config_get_database_path

2 weeks agolib: add missing status strings
David Bremner [Sun, 14 Feb 2021 17:42:42 +0000 (13:42 -0400)]
lib: add missing status strings

2 weeks agolib/open: fix leaks calling _trial_open
David Bremner [Sat, 27 Mar 2021 12:12:28 +0000 (09:12 -0300)]
lib/open: fix leaks calling _trial_open

_trial_open can't know if the PATH_ERROR return value will cause the
error message to be returned from the library, so it's up the caller
to clean up if not.

3 weeks agoCLI/new: use configuration variable for backup directory
David Bremner [Wed, 17 Feb 2021 15:26:15 +0000 (11:26 -0400)]
CLI/new: use configuration variable for backup directory

The stat is essentially replaced by the mkdir for error detection
purposes.  This changes the default location for backups to make
things tidier, even in non-split configurations. Hopefully there is
not too many user scripts relying on the previous location.

Because the default location may not exist, replace the use of stat
for error detection with a call to mkdir.

3 weeks agolib/config: add configuration variable for backup directory
David Bremner [Wed, 17 Feb 2021 15:04:54 +0000 (11:04 -0400)]
lib/config: add configuration variable for backup directory

Like the hook directory, we primarily need a way to communicate this
directory between various components, but we may as well let the user
configure it.

Most of the diff is generalizing choose_hook_dir to work for both
backup and hook directories.

3 weeks agolib/open: fix hook directory calculation in split configuration
David Bremner [Wed, 17 Feb 2021 11:16:54 +0000 (07:16 -0400)]
lib/open: fix hook directory calculation in split configuration

Choose sibling directory of xapian database, as .notmuch may not
exist.

libgen.h is already used in debugger.c, so it is not a new dependency
/ potential portability problem.

3 weeks agolib/compact: enable split config
David Bremner [Tue, 2 Feb 2021 11:51:23 +0000 (07:51 -0400)]
lib/compact: enable split config

This promotes _choose_xapian_path from static to extern linkage in
order to share between open.cc and database.cc.

3 weeks agoCLI/insert: support split database and mail root
David Bremner [Sat, 9 Jan 2021 11:29:07 +0000 (07:29 -0400)]
CLI/insert: support split database and mail root

The new test is in T055-path-config because it uses the helper
function split_config, and because it seems easier to put the
database path related tests in one place.

3 weeks agolib/open: support XDG_DATA_HOME as a fallback database location.
David Bremner [Mon, 4 Jan 2021 00:04:46 +0000 (20:04 -0400)]
lib/open: support XDG_DATA_HOME as a fallback database location.

This changes some error reporting, either intentionally by reporting
the highest level missing directory, or by side effect from looking in
XDG locations when given null database location.

3 weeks agoCLI/new: support split database and mail location
David Bremner [Sat, 9 Jan 2021 11:25:25 +0000 (07:25 -0400)]
CLI/new: support split database and mail location

This adds new state variable for the mail root, and uses it most
places db_path was used. The notable exception is dumps from
backups. The latter will be dealt with properly in a future commit.

3 weeks agolib/open: check for split configuration when creating database.
David Bremner [Wed, 17 Feb 2021 00:08:23 +0000 (20:08 -0400)]
lib/open: check for split configuration when creating database.

The main functionality will be tested when notmuch-new is converted to
support split configuration. Here only the somewhat odd case of split
mail root which is actually symlinked to the database path is tested.

3 weeks agolib: support splitting mail from database location.
David Bremner [Thu, 31 Dec 2020 22:20:31 +0000 (18:20 -0400)]
lib: support splitting mail from database location.

Introduce a new configuration value for the mail root, and use it to
locate mail messages in preference to the database.path (which
previously implied the mail messages were also in this location.

Initially only a subset of the CLI is tested in a split
configuration. Further changes will be needed for the remainder of the
CLI to work in split configurations.

3 weeks agolib/open: Use check for existing database by trial opening
David Bremner [Sun, 7 Feb 2021 16:54:45 +0000 (12:54 -0400)]
lib/open: Use check for existing database by trial opening

This is a bit heavyweight for now, but it will make more sense when we
check multiple locations for the Xapian database.

3 weeks agolib/open: use _finish_open in n_d_create_with_config
David Bremner [Sat, 30 Jan 2021 17:30:18 +0000 (13:30 -0400)]
lib/open: use _finish_open in n_d_create_with_config

This avoids reading the configuration file twice.

3 weeks agolib/open: factor out the second half of n_d_open_with_config
David Bremner [Sat, 30 Jan 2021 17:57:32 +0000 (13:57 -0400)]
lib/open: factor out the second half of n_d_open_with_config

The idea is to allow reuse in n_d_create_with_config. This is
primarily code movement, with some changes in error messages to reduce
the number of input parameters.

3 weeks agolib/open: reuse directory checks from n_d_c_with_config
David Bremner [Thu, 4 Mar 2021 13:31:13 +0000 (09:31 -0400)]
lib/open: reuse directory checks from n_d_c_with_config

Make checks more uniform between creating new databases and opening
existing ones.

3 weeks agolib/open: factor out library initialization
David Bremner [Fri, 29 Jan 2021 11:44:18 +0000 (07:44 -0400)]
lib/open: factor out library initialization

This is slightly more tidy, but more importantly it allows for re-use
of this code in n_d_create_with_config. That re-use will be crucial
when we no longer call n_d_open_with_config from
n_d_create_with_config.

3 weeks agolib: remove "path" from notmuch struct
David Bremner [Tue, 2 Feb 2021 20:43:58 +0000 (16:43 -0400)]
lib: remove "path" from notmuch struct

This removes duplication between the struct element and the
configuration string_map entry. Create a simple wrapper for setting
the database path that makes sure the trailing / is stripped.

3 weeks agolib/open: allocate notmuch_t struct early
David Bremner [Wed, 27 Jan 2021 00:46:44 +0000 (20:46 -0400)]
lib/open: allocate notmuch_t struct early

This gives more flexibility in restructuring the database opening
code.

3 weeks agolib/open: support NOTMUCH_DATABASE environment variable
David Bremner [Sat, 26 Dec 2020 03:22:23 +0000 (23:22 -0400)]
lib/open: support NOTMUCH_DATABASE environment variable

The additional code is trivial, but making sure we get the priority of
various options correct takes a few tests.

3 weeks agoCLI/show: complete conversion to new configuration framework.
David Bremner [Sat, 6 Feb 2021 22:50:20 +0000 (18:50 -0400)]
CLI/show: complete conversion to new configuration framework.

In order to open the database in main() for this command, we may need
to re-open it in the (possibly less common) case where crypto options
require write access.

3 weeks agoCLI/new: drop the write lock to run the pre-new hook.
David Bremner [Fri, 19 Mar 2021 01:58:02 +0000 (22:58 -0300)]
CLI/new: drop the write lock to run the pre-new hook.

This fixes a bug reported in [1]. In principle it could be possible
avoid one of these reopens, but it complicates the logic in main with
respect to creating new databases.

[1]: id:9C1993DF-84BD-4199-A9C8-BADA98498812@bubblegen.co.uk

3 weeks agotest: Add tests for write access to database from hooks.
David Bremner [Fri, 19 Mar 2021 01:54:13 +0000 (22:54 -0300)]
test: Add tests for write access to database from hooks.

Recent changes to configuration handling meant the pre-new hook was
run while the database was open read only, limiting what could be done
in the hook. Add some known broken tests for this problem, as well as
a regression test for write access from the post-new hook.

3 weeks agolib: support reopening databases for write access.
David Bremner [Sun, 14 Mar 2021 14:01:59 +0000 (11:01 -0300)]
lib: support reopening databases for write access.

In the future Xapian will apparently support this more conveniently
for the cases other than READ_ONLY => READ_ONLY

Conceptually this function seems to fit better in lib/open.cc;
database.cc is still large enough that moving the function makes
sense.

3 weeks agolib: save path of xapian database in notmuch struct.
David Bremner [Sun, 14 Mar 2021 14:01:58 +0000 (11:01 -0300)]
lib: save path of xapian database in notmuch struct.

This will allow re-opening in a different mode (read/write
vs. read-only) with current Xapian API. It will also prove useful when
updating the compact functions to support more flexible database
location.

3 weeks agolib: publish API for notmuch_database_reopen
David Bremner [Sun, 14 Mar 2021 14:01:57 +0000 (11:01 -0300)]
lib: publish API for notmuch_database_reopen

Include the (currently unused) mode argument which will specify which
mode to re-open the database in. Functionality and docs to be
finalized in a followup commit.

3 weeks agotest/setup: add check for config exists, but no database.
David Bremner [Sun, 14 Mar 2021 14:01:56 +0000 (11:01 -0300)]
test/setup: add check for config exists, but no database.

This code path is not currently tested, and will need updating if the
location of the xapian database changes.

3 weeks agotest: add known broken test for long directory bug
David Bremner [Thu, 18 Mar 2021 01:20:35 +0000 (22:20 -0300)]
test: add known broken test for long directory bug

In [1] Gregor Zattler explained the results of his hard work
tracking down a bug in notmuch with long directories. This test
duplicates the bug.

[1]: id:20210317194728.GB5561@no.workgroup

4 weeks agolib/open: free GKeyFile
David Bremner [Sat, 6 Mar 2021 13:49:34 +0000 (09:49 -0400)]
lib/open: free GKeyFile

This fixes a small-to-medium (depending on size of config file) memory
leak.

4 weeks agolib/config: free memory from traversing GKeyFile
David Bremner [Sat, 6 Mar 2021 13:49:33 +0000 (09:49 -0400)]
lib/config: free memory from traversing GKeyFile

This fixes a few small memory leaks.

4 weeks agolib/open: free value from g_key_file_get_value
David Bremner [Sat, 6 Mar 2021 13:49:32 +0000 (09:49 -0400)]
lib/open: free value from g_key_file_get_value

This fixes a small memory leak.

4 weeks agolib/open: use local talloc context in n_d_create_with_config
David Bremner [Sat, 6 Mar 2021 13:49:31 +0000 (09:49 -0400)]
lib/open: use local talloc context in n_d_create_with_config

This better matches the memory allocation semantics in
notmuch_database_open_with_config.

4 weeks agocli: run uncrustify
uncrustify [Sat, 13 Mar 2021 12:45:34 +0000 (08:45 -0400)]
cli: run uncrustify

This is the result of running

     $ uncrustify --replace --config devel/uncrustify.cfg *.c *.h

in the top level source directory

Line breaks were then adjusted manually to keep argc and argv
together.

4 weeks agotest: run uncrustify
uncrustify [Sat, 13 Mar 2021 12:45:34 +0000 (08:45 -0400)]
test: run uncrustify

This is the result of running:

    $ uncrustify --replace --config ../devel/uncrustify.cfg *.cc *.c *.h

in the test directory.

4 weeks agoutil: run uncrustify
uncrustify [Sat, 13 Mar 2021 12:45:34 +0000 (08:45 -0400)]
util: run uncrustify

This is the result of running

     $ uncrustify --replace --config ../devel/uncrustify.cfg *.c *.h

in the util directory

4 weeks agolib: run uncrustify
uncrustify [Sat, 13 Mar 2021 12:45:34 +0000 (08:45 -0400)]
lib: run uncrustify

This is the result of running

     $ uncrustify --replace --config ../devel/uncrustify.cfg *.c *.h *.cc

in the lib directory

4 weeks agotest: clean up some extra whitespace.
David Bremner [Sat, 16 Jan 2021 01:29:17 +0000 (21:29 -0400)]
test: clean up some extra whitespace.

The extra space is mainly just untidy.

4 weeks agotest: T020-compact.sh: fix work directory location
Tomi Ollila [Thu, 25 Feb 2021 20:04:30 +0000 (22:04 +0200)]
test: T020-compact.sh: fix work directory location

Fix use of $TEST_DIRECTORY ($NOTMUCH_BUILDDIR/test/) with use of
$TMP_DIRECTORY ($NOTMUCH_BUILDDIR/test/tmp.T020-compact/ in case
of T020-compact.sh) as root directory where to write test files
and directories.

4 weeks agodevel/uncrustify: add line length limits.
David Bremner [Sun, 7 Mar 2021 19:44:46 +0000 (15:44 -0400)]
devel/uncrustify: add line length limits.

A generous limit of 102 is chosen to moderate the amount of resulting
reformatting.

7 weeks agoMerge tag '0.31.4'
David Bremner [Thu, 18 Feb 2021 12:47:53 +0000 (08:47 -0400)]
Merge tag '0.31.4'

notmuch 0.31.4 release

7 weeks agodebian: drop patches release 0.31.4 archive/debian/0.31.4-1 debian/0.31.4-1
David Bremner [Thu, 18 Feb 2021 11:53:00 +0000 (07:53 -0400)]
debian: drop patches

we should by synced up with the tarball again

7 weeks agodoc: bump copyright year
David Bremner [Thu, 18 Feb 2021 11:52:39 +0000 (07:52 -0400)]
doc: bump copyright year

7 weeks agodebian: changelog for 0.31.4-1
David Bremner [Thu, 18 Feb 2021 11:23:24 +0000 (07:23 -0400)]
debian: changelog for 0.31.4-1

7 weeks agoNEWS: news for 0.31.4
David Bremner [Thu, 18 Feb 2021 11:21:48 +0000 (07:21 -0400)]
NEWS: news for 0.31.4

7 weeks agoversion: update to 0.31.4
David Bremner [Thu, 18 Feb 2021 11:17:22 +0000 (07:17 -0400)]
version: update to 0.31.4

7 weeks agotest: Fix race condition in T568-lib-thread.sh
David Bremner [Mon, 15 Feb 2021 00:55:55 +0000 (20:55 -0400)]
test: Fix race condition in T568-lib-thread.sh

The assignment of thread-ids is (apparently) non-deterministic in a
way that mostly seems to show up on multicore machines. In my tests
the number is different from that previously assumed by this test
about 15% of the time on a 50 thread (25 core) Xeon.

Since message id's are fixed, use a message known to be in the thread
of interest to pick out the correct thread-id.

8 weeks agofix build failure with glib 2.67
David Bremner [Mon, 15 Feb 2021 20:43:50 +0000 (16:43 -0400)]
fix build failure with glib 2.67

Based on a patch from Michael J Gruber [1].  As of glib 2.67 (more
specifically [2]), including "gmime-extra.h" inside an extern "C"
block causes build failures, because glib is using C++ features.

Observing that "gmime-extra.h" is no longer needed in
notmuch-private.h, which can simply delete that include, but
we have to correspondingly move the includes which might include
it (in particular crypto.h) out of the extern "C" block also.

This seems less fragile than only moving gmime-extra, and relying on
preprocessor sentinels to keep the deeper includes from happening.

Move to the include to the outside of the extern block.

[1]: id:aee618a3d41f7889a7449aa16893e992325a909a.1613055071.git.git@grubix.eu
[2]: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1715

8 weeks agopython: convert shebangs to python3
Daniel Kahn Gillmor [Sat, 13 Feb 2021 00:26:22 +0000 (19:26 -0500)]
python: convert shebangs to python3

This is the last bit of "python" left in the notmuch codebase.

https://www.python.org/dev/peps/pep-0394/#recommendation encourages
"third-party distributors" to use more-specific shebang lines.  I'm
not certain that the notmuch project itself is a "third-party
contributor" but I think this is a safe way to encourage people to use
python3 when they're developing notmuch.

We already have python3 explicitly elsewhere in the codebase for
developers (in nmbug).

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
8 weeks agolib: use a stricter unused macro
David Bremner [Mon, 15 Feb 2021 02:28:55 +0000 (22:28 -0400)]
lib: use a stricter unused macro

This would have caught bugs like the one corrected in the previous commit.

8 weeks agolib/open: remove incorrect unused attribute
David Bremner [Mon, 15 Feb 2021 02:27:51 +0000 (22:27 -0400)]
lib/open: remove incorrect unused attribute

With the current unused macro in lib/notmuch-private.h this seems
harmless, but is misleading, since the parameter is in fact used.

2 months agolib: add missing private status values.
David Bremner [Fri, 22 Jan 2021 11:34:51 +0000 (07:34 -0400)]
lib: add missing private status values.

Many public status values have been added without being copied to the
list of private status values.

2 months agodoc: describe new config framework
David Bremner [Sun, 10 Jan 2021 15:54:35 +0000 (11:54 -0400)]
doc: describe new config framework

Remove STORED IN DATABASE discussion, describe search rules.
Currently profiles seem a bit pointless. They will make more sense
when they apply to databases as well.

2 months agoCLI: use configured hook directory
David Bremner [Sun, 10 Jan 2021 11:50:14 +0000 (07:50 -0400)]
CLI: use configured hook directory

This enables support for hooks outside the database directory.
It relies strongly on configuration information being usable between
closing the database and destroying it.

2 months agolib/open: set HOOK_DIR on open
David Bremner [Sat, 9 Jan 2021 19:05:58 +0000 (15:05 -0400)]
lib/open: set HOOK_DIR on open

This is a simple two step path search.  Most error checking is
deferred until running the hooks.

2 months agolib/config: add HOOK_DIR
David Bremner [Sat, 9 Jan 2021 13:19:50 +0000 (09:19 -0400)]
lib/config: add HOOK_DIR

The hook directory configuration needs to be kept in synch with the
other configuration information, so add scaffolding to support this at
database opening time.

2 months agocli/new: convert to new config framework
David Bremner [Sat, 2 Jan 2021 17:10:39 +0000 (13:10 -0400)]
cli/new: convert to new config framework

In addition to the same type of changes as converting other
subcommands, add the possibility of creating a database at the top
level. It would probably make sense to use this for insert as well.

2 months agocli/new: refactor database upgrade code
David Bremner [Sat, 2 Jan 2021 03:19:31 +0000 (23:19 -0400)]
cli/new: refactor database upgrade code

Move to a separate function. This is essentially just code movement.

2 months agolib: introduce notmuch_database_create_with_config
David Bremner [Sat, 2 Jan 2021 00:43:14 +0000 (20:43 -0400)]
lib: introduce notmuch_database_create_with_config

This takes a config path parameter, and can use that to decide the
new database location.

2 months agolib: add NOTMUCH_STATUS_DATABASE_EXISTS
David Bremner [Sun, 3 Jan 2021 12:50:12 +0000 (08:50 -0400)]
lib: add NOTMUCH_STATUS_DATABASE_EXISTS

It is desirable to distinguish between attempting to create a database
that already exists, and more fatal errors like permission problems.

2 months agolib/database: move n_d_create* to open.cc
David Bremner [Sat, 2 Jan 2021 00:22:00 +0000 (20:22 -0400)]
lib/database: move n_d_create* to open.cc

This will help share code with n_d_open_with_config.

2 months agolib: add NOTMUCH_STATUS_NO_CONFIG
David Bremner [Sun, 3 Jan 2021 12:30:46 +0000 (08:30 -0400)]
lib: add NOTMUCH_STATUS_NO_CONFIG

This will allow client code to provide more meaningful diagnostics. In
particular it will enable "notmuch new" to continue suggsting the user
run "notmuch setup" to create a config after "notmuch new" is
transitioned to the new  configuration framework.

2 months agolib/open: factor out choosing database path
David Bremner [Fri, 1 Jan 2021 16:16:25 +0000 (12:16 -0400)]
lib/open: factor out choosing database path

The plan is to share code with a new database creation function that
has a similar API to n_d_open_with_config.

2 months agolib/config: add NOTMUCH_CONFIG_NEW_IGNORE
David Bremner [Fri, 1 Jan 2021 13:01:24 +0000 (09:01 -0400)]
lib/config: add NOTMUCH_CONFIG_NEW_IGNORE

This will be needed by (at least) the conversion of notmuch-new.c to
the new config framework

2 months agobindings/notmuch2: add missing crypto error status codes
David Bremner [Sun, 3 Jan 2021 01:50:24 +0000 (21:50 -0400)]
bindings/notmuch2: add missing crypto error status codes

These are needed so that the later codes line up numerically.

2 months agocli/compact: convert to new configuration framework
David Bremner [Thu, 24 Dec 2020 03:45:23 +0000 (23:45 -0400)]
cli/compact: convert to new configuration framework

Switch to the newly created API function notmuch_database_compact_db,
which takes the database opened in main().

2 months agolib: split notmuch_database_compact
David Bremner [Thu, 24 Dec 2020 03:37:41 +0000 (23:37 -0400)]
lib: split notmuch_database_compact

The "back end" function takes an open notmuch database, which should
know its own path (i.e. the path needs to be cached in the
configuration data).

2 months agolib/config: add _notmuch_config_cache
David Bremner [Thu, 24 Dec 2020 03:35:42 +0000 (23:35 -0400)]
lib/config: add _notmuch_config_cache

This is a simple convenience routine to cache a configuration value
without writing it to the database.

2 months agocli/tag: convert to new config framework.
David Bremner [Mon, 7 Dec 2020 23:48:48 +0000 (19:48 -0400)]
cli/tag: convert to new config framework.

In addition to changing configuration access, change talloc context
for allocation.

2 months agoCLI/show: mostly switch show to new config framework
David Bremner [Sat, 8 Aug 2020 14:16:53 +0000 (11:16 -0300)]
CLI/show: mostly switch show to new config framework

This will need some cleanup when the transition completes, and we stop
passing notmuch_config_t structs to the subcommands.

Unlike the general case, we open the database in the subcommand, since
we don't know whether it should be opened read/write until we parse
the command line arguments.

Add a test to make sure passing config file on the command line is not
broken by these or future config related changes.

2 months agocli/config: add accessor for config file name
David Bremner [Sat, 8 Aug 2020 14:16:51 +0000 (11:16 -0300)]
cli/config: add accessor for config file name

This is intended for use in temporary code transitioning to the new
configuration system. The name is chosen to avoid cluttering the
notmuch_config_* namespace further with non-library functions.

2 months agoCLI/{search,address}: convert to new configuration framework
David Bremner [Sat, 8 Aug 2020 14:16:52 +0000 (11:16 -0300)]
CLI/{search,address}: convert to new configuration framework

Since we are already passing a search context around as a kind of
parameter block, add a new talloc context to that to replace relying
on 'config'.

Convert notmuch-search and notmuch-address at the same time, because
they share some code.

Add a test to make sure we don't break passing configuration as a
command line argument.

2 months agoCLI/reply: convert to new config framework
David Bremner [Sun, 8 Nov 2020 01:58:32 +0000 (21:58 -0400)]
CLI/reply: convert to new config framework

This is messier than some of the other conversions because the
extensive use of 'config' as a talloc context.

2 months agocli/reindex: convert new config framework
David Bremner [Mon, 5 Oct 2020 23:35:26 +0000 (20:35 -0300)]
cli/reindex: convert new config framework

The only non-trivial part is switching the talloc context for
query_string_from args from 'config' to 'notmuch'.

2 months agoCLI/insert: convert to new config framework.
David Bremner [Wed, 26 Aug 2020 11:43:33 +0000 (08:43 -0300)]
CLI/insert: convert to new config framework.

The new talloc context is needed to run the hook at the very end of
the function. That in turn is needed so that this process gives up the
write lock on the database.

2 months agoCLI/restore: convert to new config framework
David Bremner [Mon, 5 Oct 2020 23:28:29 +0000 (20:28 -0300)]
CLI/restore: convert to new config framework

Switch one configuration check to new n_c_get_bool function, and
switch use of config as talloc context to notmuch.