]> git.notmuchmail.org Git - notmuch/log
notmuch
2 years agoCLI/config: restore "notmuch config get built_with.*"
David Bremner [Sun, 18 Jul 2021 17:58:22 +0000 (14:58 -0300)]
CLI/config: restore "notmuch config get built_with.*"

We need to special case the config section "built_with" because it is
not (currently) handled by the library. This seems consist with the
other sub-sub-commands 'list' and 'set'.

2 years agotest/config: add tests for built_with
David Bremner [Sun, 18 Jul 2021 17:58:21 +0000 (14:58 -0300)]
test/config: add tests for built_with

The "get" test is known broken because this functionality was dropped
during the 0.32 config rewrite.

2 years agolib/open: look in MAILDIR for database, as documented.
David Bremner [Wed, 4 Aug 2021 10:42:35 +0000 (07:42 -0300)]
lib/open: look in MAILDIR for database, as documented.

This fixes the bug id:87bl9lx864.fsf@kisara.moe

2 years agotest: add known broken tests for finding database via MAILDIR
David Bremner [Wed, 4 Aug 2021 10:42:34 +0000 (07:42 -0300)]
test: add known broken tests for finding database via MAILDIR

This highlights a bug reported by several users, including
Mohsin Kaleem [1].

The inconsistent use of test_begin_subtest_known_broken is because
some of these tests pass even though the database cannot be
located. This problem is left for a future commit.

[1]: id:87bl9lx864.fsf@kisara.moe

2 years agolib: bump libnotmuch minor version
Austin Ray [Fri, 13 Aug 2021 16:50:28 +0000 (12:50 -0400)]
lib: bump libnotmuch minor version

Notmuch 0.32 corresponds to libnotmuch 5.4 as indicated by docstrings;
however, the minor number wasn't bumped. Any libnotmuch downstream
consumer using the LIBNOTMUCH_CHECK_VERSION macro to support multiple
versions won't be able to access the new 5.4 functions.

Signed-off-by: Austin Ray <austin@austinray.io>
2 years agolib: correct deprecated db open functions' docs
Austin Ray [Sat, 14 Aug 2021 22:39:17 +0000 (18:39 -0400)]
lib: correct deprecated db open functions' docs

Both notmuch_database_open() and notmuch_database_open_verbose()'s
documentation state they call notmuch_database_open_with_config() with
config_path=NULL; however, their implementations pass an empty string.
The empty string is the correct value to maintain their original
behavior of not loading the user's configuration so their documentation
is incorrect.

2 years agoNEWS: finalize for 0.32.2 0.32.2
David Bremner [Sun, 27 Jun 2021 11:56:21 +0000 (08:56 -0300)]
NEWS: finalize for 0.32.2

2 years agodebian: changelog for 0.32.2-1
David Bremner [Sun, 27 Jun 2021 01:34:30 +0000 (22:34 -0300)]
debian: changelog for 0.32.2-1

2 years agoNEWS: mention fix for memory leak.
David Bremner [Sun, 27 Jun 2021 01:26:09 +0000 (22:26 -0300)]
NEWS: mention fix for memory leak.

2 years agolib/config: fix memory leak
David Bremner [Sat, 19 Jun 2021 00:59:44 +0000 (21:59 -0300)]
lib/config: fix memory leak

This commit fixes a small memory leak (per iterator restart) by
actually using the talloc context intended to be blown away on
restart.

2 years agoversion: bump to 0.32.2
David Bremner [Fri, 25 Jun 2021 12:02:54 +0000 (09:02 -0300)]
version: bump to 0.32.2

2 years agodoc: tweak hook configuration documentation.
David Bremner [Tue, 22 Jun 2021 23:08:13 +0000 (20:08 -0300)]
doc: tweak hook configuration documentation.

Add a historical note, and hint to look below for more about hooks.
Capitalized the heading for consistency, removed blank line.

2 years agoNEWS: fix typo
David Bremner [Sun, 20 Jun 2021 19:59:30 +0000 (16:59 -0300)]
NEWS: fix typo

Oops. Apparently our release checks do not check the spelling of
UNRELEASED (although Tomi's wiki conversion script does).

2 years agoNEWS: start NEWS for 0.32.2
David Bremner [Sun, 20 Jun 2021 19:41:03 +0000 (16:41 -0300)]
NEWS: start NEWS for 0.32.2

2 years agoemacs: require seq for seq-some
David Bremner [Tue, 8 Jun 2021 23:12:33 +0000 (20:12 -0300)]
emacs: require seq for seq-some

Although the function dates from 2015, the autoload is newer. In
particular [1] it is not found in Emacs 25.3.

[1]: id:874ke85tqx.fsf@cgc-instruments.com

2 years agotest: check openssl prequisite for add_gpgsm_home
David Bremner [Tue, 8 Jun 2021 19:39:10 +0000 (16:39 -0300)]
test: check openssl prequisite for add_gpgsm_home

This is a fix for the test failures reported by Dan Čermák [1].

It is more robust to check for the prerequisite inside the function
that uses it, rather than in every test file that calls the function.

[1]: id:87k0n4fqgm.fsf@tethera.net

2 years agoNEWS/emacs: document changes in 0.32 that affect keybindings.
Daniel Kahn Gillmor [Thu, 27 May 2021 16:58:37 +0000 (12:58 -0400)]
NEWS/emacs: document changes in 0.32 that affect keybindings.

See list discussion in thread starting with
id:87h7ip2baq.fsf@fifthhorseman.net for more details.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Amended-by: David Bremner (s/.emacs/Emacs configuration/)
2 years agolib/n_d_index_file: re-use thread-id of existing message
David Bremner [Sat, 15 May 2021 18:40:22 +0000 (15:40 -0300)]
lib/n_d_index_file: re-use thread-id of existing message

This prevents the message document getting multiple thread-id terms
when there are multiple files with the same message-id.

This change shifts some thread ids, requiring adjustments to other tests.

2 years agotest: add known broken test for duplicate thread-id terms
David Bremner [Sat, 15 May 2021 13:05:07 +0000 (10:05 -0300)]
test: add known broken test for duplicate thread-id terms

According to my bijection, this bug has been present since commit
411675a6ce in 2017. It is not completely clear what harm it causes in
regulary use, but it (at least) makes notmuch crash when compiled with
-DDEBUG_DATABASE_SANITY.

2 years agoperf-test/T00-new: fix backup creation.
David Bremner [Sat, 8 May 2021 13:57:35 +0000 (10:57 -0300)]
perf-test/T00-new: fix backup creation.

"xargs tar cf backup.tar < $manifest" recreates the tar file with each
"batch" execed by xargs. In general this results in only a fraction of
the desired files being backed up.

2 years agodoc: fix variable name in documentation
Luis Henriques [Wed, 19 May 2021 11:08:18 +0000 (12:08 +0100)]
doc: fix variable name in documentation

Variable 'notmuch-saved-searches-sort-function' does not exist;
'notmuch-saved-search-sort-function' is the correct name.

Signed-off-by: Luis Henriques <henrix@camandro.org>
2 years agodoc: fix man page build for Sphinx 4.x
Jani Nikula [Tue, 18 May 2021 21:40:44 +0000 (00:40 +0300)]
doc: fix man page build for Sphinx 4.x

Sphinx 4.0 changed the default value of man_make_section_directory
from False to True. We create the section directories and move the
files manually, so fix the immediate man build failure by disabling
the feature.

The Sphinx documentation on this [1] is confusing, and has the change
backwards. Git history says the default changed from False to True.

[1] https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-man_make_section_directory

2 years agoNEWS: finalize release date 0.32.1 archive/debian/0.32.1-1 debian/0.32.1-1
David Bremner [Sat, 15 May 2021 12:04:20 +0000 (09:04 -0300)]
NEWS: finalize release date

2 years agodebian: changelog for 0.32.1-1
David Bremner [Sat, 15 May 2021 12:03:19 +0000 (09:03 -0300)]
debian: changelog for 0.32.1-1

2 years agoversion: bump to 0.32.1
David Bremner [Sat, 15 May 2021 11:59:01 +0000 (08:59 -0300)]
version: bump to 0.32.1

2 years agoNEWS: add news for $HOME/mail fix
David Bremner [Sat, 15 May 2021 11:52:47 +0000 (08:52 -0300)]
NEWS: add news for $HOME/mail fix

2 years agolib/open: restore default database path of $HOME/mail
David Bremner [Mon, 10 May 2021 10:39:18 +0000 (07:39 -0300)]
lib/open: restore default database path of $HOME/mail

Although this default worked for "notmuch config get", it didn't work
most other places. Restore the previous functionality, with the
wrinkle that XDG locations will shadow $HOME/mail if they exist.

This fixes a bug reported by Jack Kamm in id:87eeefdc8b.fsf@gmail.com

2 years agoNEWS: add NEWS for notmuch-{before,after}-tag-hook fixes
David Bremner [Sat, 8 May 2021 12:11:13 +0000 (09:11 -0300)]
NEWS: add NEWS for notmuch-{before,after}-tag-hook fixes

2 years agoemacs: restore tag-changes and query bindings for tag hooks
Kyle Meyer [Sat, 8 May 2021 12:11:12 +0000 (09:11 -0300)]
emacs: restore tag-changes and query bindings for tag hooks

notmuch-before-tag-hook and notmuch-after-tag-hook are supposed to
have access to two dynamic variables, tag-changes and query, but these
were lost with the switch to lexical binding in fc4cda07 (emacs: use
lexical-bindings in all libraries, 2021-01-13).

Add a variant of Emacs's dlet (not available until Emacs 28) and use
it in notmuch-tag to expose tag-changes and query to the hooks.

2 years agotest: add known broken tests for notuch-{before,after}-tag-hook
David Bremner [Sat, 8 May 2021 12:11:11 +0000 (09:11 -0300)]
test: add known broken tests for notuch-{before,after}-tag-hook

These tests illustrate the bug reported in id:87v97ytd2s.fsf@fastmail.fm

2 years agoNEWS: add note about fix to notmuch_database_reopen
David Bremner [Tue, 11 May 2021 22:50:51 +0000 (19:50 -0300)]
NEWS: add note about fix to notmuch_database_reopen

2 years agolib/notmuch_database_reopen: reload some database metadata
David Bremner [Sun, 9 May 2021 12:28:48 +0000 (09:28 -0300)]
lib/notmuch_database_reopen: reload some database metadata

In some uses of reopen, new documents and threads maybe have been
added, and e.g. compaction may have changed the uuid.

2 years agotest: change database from within pre-new hook
Michael J Gruber [Tue, 11 May 2021 20:48:52 +0000 (22:48 +0200)]
test: change database from within pre-new hook

Due to the change in the config system, notmuch keeps a notmuch database
open when it would not do so before. Consequently, it can miss changes
to the database which are done from a hook (while notmuch holds the
databse in read only mode). When notmuch itself writes to the database
after that it uses wrong assumptions about the last used doc id etc.

Demonstrate this by triggering an assertion. (This new test succeeds
with notmuch 0.31.4.)

Signed-off-by: Michael J Gruber <git@grubix.eu>
Amended-by: db. Check for both messages
2 years agoNEWS: start NEWS for 0.32.1
David Bremner [Fri, 7 May 2021 11:07:33 +0000 (08:07 -0300)]
NEWS: start NEWS for 0.32.1

2 years agodoc: document database.backup_dir
David Bremner [Fri, 7 May 2021 11:13:22 +0000 (08:13 -0300)]
doc: document database.backup_dir

Most users will not need to change this, but documenting it helps
preserve the interface.

2 years agodoc: document (tersely) the intended behaviour of relative paths.
David Bremner [Fri, 7 May 2021 11:02:16 +0000 (08:02 -0300)]
doc: document (tersely) the intended behaviour of relative paths.

2 years agotest: test explicit configuration of backup directory
David Bremner [Fri, 7 May 2021 10:56:08 +0000 (07:56 -0300)]
test: test explicit configuration of backup directory

Including the relative path that was broken until a recent commit.

2 years agotest: test relative paths for database.hook_dir
David Bremner [Fri, 7 May 2021 10:38:32 +0000 (07:38 -0300)]
test: test relative paths for database.hook_dir

2 years agolib/config: expand relative paths when reading from database
David Bremner [Fri, 7 May 2021 10:27:37 +0000 (07:27 -0300)]
lib/config: expand relative paths when reading from database

This makes the treatment of relative paths consistent between the
database and config files.

2 years agotest: add known broken test for relative setting of mail_root
David Bremner [Fri, 7 May 2021 10:17:43 +0000 (07:17 -0300)]
test: add known broken test for relative setting of mail_root

The behaviour should not change depending on where the configuration
is stored.

2 years agolib/config: canonicalize paths relative to $HOME.
David Bremner [Fri, 7 May 2021 00:16:38 +0000 (21:16 -0300)]
lib/config: canonicalize paths relative to $HOME.

Prior to 0.32, notmuch had the (undocumented) behaviour that it
expanded a relative value of database.path with respect to $HOME. In
0.32 this was special cased for database.path but broken for
database.mail_root, which causes problems for at least notmuch-new
when database.path is set to a relative path.

The change in T030-config.sh reflects a user visible, but hopefully
harmless behaviour change; the expanded form of the paths will now be
printed by notmuch config.

2 years agotest: add known broken test for relative database path in new
David Bremner [Thu, 6 May 2021 22:55:07 +0000 (19:55 -0300)]
test: add known broken test for relative database path in new

This test highlights a bug introduced in 0.32. The new split between
path and mail_root does not properly canonicalize relative paths in
the latter.

2 years agodebian: add changelog for 0.32-1 0.32 archive/debian/0.32-1 debian/0.32-1
David Bremner [Sun, 2 May 2021 10:05:44 +0000 (07:05 -0300)]
debian: add changelog for 0.32-1

2 years agoNEWS: set date for 0.32 release
David Bremner [Sun, 2 May 2021 10:01:41 +0000 (07:01 -0300)]
NEWS: set date for 0.32 release

2 years agoversion: bump to 0.32
David Bremner [Sun, 2 May 2021 10:00:15 +0000 (07:00 -0300)]
version: bump to 0.32

2 years agodebian: add changelog for 0.32~rc2-1 0.32_rc2 archive/debian/0.32_rc2-1 debian/0.32_rc2-1
David Bremner [Wed, 28 Apr 2021 10:06:31 +0000 (07:06 -0300)]
debian: add changelog for 0.32~rc2-1

2 years agoversion: bump to 0.32~rc2
David Bremner [Wed, 28 Apr 2021 10:04:57 +0000 (07:04 -0300)]
version: bump to 0.32~rc2

2 years agoNEWS: fix typo
David Bremner [Wed, 28 Apr 2021 10:01:53 +0000 (07:01 -0300)]
NEWS: fix typo

Spellcheckers, is that like spellchess?

2 years agoNEWS: summarize changes to emacs interface.
David Bremner [Tue, 27 Apr 2021 00:12:02 +0000 (21:12 -0300)]
NEWS: summarize changes to emacs interface.

This my attempt at a summary based on git log.

Amended: with suggestions from id:87wnsmkf12.fsf@bernoul.li

3 years agoNEWS: mention file deletion speedups
David Bremner [Mon, 26 Apr 2021 23:53:01 +0000 (20:53 -0300)]
NEWS: mention file deletion speedups

It seems a bit silly to have two NEWS entries for one commit, but
there are two potiential audiences.

3 years agovim: fix Mail 2.8.0 warning
Felipe Contreras [Sun, 18 Apr 2021 22:48:39 +0000 (17:48 -0500)]
vim: fix Mail 2.8.0 warning

  Passing an unparsed header field to Mail::Field.new is deprecated and will be removed in Mail 2.8.0. Use Mail::Field.parse instead.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
3 years agotest: hide message from moreutils parallel.
David Bremner [Mon, 26 Apr 2021 12:00:11 +0000 (09:00 -0300)]
test: hide message from moreutils parallel.

The argument --version confuses moreutils parallel, but this is OK,
because its confusing does not include printing "GNU"

3 years agotest: check for GNU parallel with --version options
Tobias Backer Dirks [Sat, 24 Apr 2021 20:41:03 +0000 (21:41 +0100)]
test: check for GNU parallel with --version options

The lastest versions of GNU parallel no longer make mention of GNU
within their help output. This causes the test script to mistakenly use
the moreutils parallel execution. In order to fix this, while
maintaining compatibility with previous versions of GNU parallel,
--version should be used.

Signed-off-by: Tobias Backer Dirks <omgitsaheadcrab@gmail.com>
3 years agodebian: bump changelog version 0.32_rc1 archive/debian/0.32_rc1-1 debian/0.32_rc1-1
David Bremner [Sat, 24 Apr 2021 15:46:32 +0000 (12:46 -0300)]
debian: bump changelog version

3 years agoversion: bump to 0.32~rc1
David Bremner [Sat, 24 Apr 2021 15:26:09 +0000 (12:26 -0300)]
version: bump to 0.32~rc1

3 years agodebian: add xapian-tools for tests
David Bremner [Sat, 24 Apr 2021 15:13:37 +0000 (12:13 -0300)]
debian: add xapian-tools for tests

xapian-metadata is used by some of the new tests.

3 years agolib/config: remove early free in _get_email_from_passwd_file
David Bremner [Sat, 24 Apr 2021 13:44:28 +0000 (10:44 -0300)]
lib/config: remove early free in _get_email_from_passwd_file

This (obvious) bug was caused by cut&pasting the code from
notmuch-config.c into the library and adding on a return at the end.

3 years agotest: replace notmuch_passwd_sanitize with python version
David Bremner [Sat, 24 Apr 2021 12:28:15 +0000 (09:28 -0300)]
test: replace notmuch_passwd_sanitize with python version

Apparently the -f option to hostname is not portable, and in fact it
does not seem to always behave reasonably in e.g. a chroot.

Python code originally due to Tomi [1], modified by yours truly.

[1]: id:m2lf9fbkug.fsf@guru.guru-group.fi

3 years agodebian: update d/libnotmuch5 0.32_rc0
David Bremner [Sat, 24 Apr 2021 11:55:45 +0000 (08:55 -0300)]
debian: update d/libnotmuch5

This corresponds to libnotmuch 5.3. It should be backward compatible
because it only adds symbols.

3 years agodebian: start changelog for 0.32~rc0-1
David Bremner [Sat, 24 Apr 2021 11:49:44 +0000 (08:49 -0300)]
debian: start changelog for 0.32~rc0-1

3 years agoupdate version to 0.32~rc0
David Bremner [Sat, 24 Apr 2021 11:45:54 +0000 (08:45 -0300)]
update version to 0.32~rc0

3 years agocompat: rename {,notmuch_}canonicalize_file_name
Đoàn Trần Công Danh [Sat, 24 Apr 2021 01:05:37 +0000 (08:05 +0700)]
compat: rename {,notmuch_}canonicalize_file_name

When compat canonicalize_file_name was introduced, it was limited to
C code only because it was used by C code only during that time.

>From 5ec6fd4d, (lib/open: check for split configuration when creating
database., 2021-02-16), lib/open.cc, which is C++, relies on the
existent of canonicalize_file_name.

However, we can't blindly enable canonicalize_file_name for C++ code,
because different implementation has different additional signature for
C++ and users can arbitrarily add -DHAVE_CANONICALIZE_FILE_NAME=0 to
{C,CXX}FLAGS.

Let's move our implementation into a util library.

Helped-by: Tomi Ollila <tomi.ollila@iki.fi>
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
3 years agoruby: fix ruby 3.1 warnings
Felipe Contreras [Fri, 16 Apr 2021 20:27:31 +0000 (15:27 -0500)]
ruby: fix ruby 3.1 warnings

  init.c:214:5: warning: ‘rb_cData’ is deprecated: by: rb_cObject.  Will be removed in 3.1. [-Wdeprecated-declarations]

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
3 years agolib/n_d_index_file: check return value from _n_m_add_filename
David Bremner [Sat, 20 Mar 2021 13:10:52 +0000 (10:10 -0300)]
lib/n_d_index_file: check return value from _n_m_add_filename

Ignoring this return value seems like a bad idea in general, and in
particular it has been hiding one or more bugs related to handling
long directory names.

3 years agotest-lib: unset XDG_CONFIG_HOME
Đoàn Trần Công Danh [Sun, 18 Apr 2021 03:48:46 +0000 (10:48 +0700)]
test-lib: unset XDG_CONFIG_HOME

lib/open.cc:_load_key_file will only open xdg-config files in
$XDG_CONFIG_HOME if it's defined, $HOME/.config will be considered if
and only if XDG_CONFIG_HOME not defined.

Let's unset said variable before running the test.

3 years agolib: directly traverse postlists in _n_message_delete
David Bremner [Fri, 16 Apr 2021 12:00:39 +0000 (09:00 -0300)]
lib: directly traverse postlists in _n_message_delete

This is intended to fix the slow behaviour of "notmuch new" (and possibly
"notmuch reindex") when large numbers of files are deleted.

The underlying issue [1] seems to be the Xapian glass backend spending
a large amount of time in db.has_positions when running queries with
large-ish amounts of unflushed changes.

This commit removes two uses of Xapian queries [2], and replaces them with
an approximation of what Xapian would do after optimizing the
queries. This avoids the calls to has_positions (which are in any case
un-needed because we are only using boolean terms here).

[1] Thanks to "andres" on IRC for narrowing down the performance
bottleneck.

[2] Thanks to Olly Betts of Xapian fame for talking me a through a fix
that does not require people to update Xapian.

3 years agoperf-tests: add test for removing files.
David Bremner [Fri, 16 Apr 2021 12:00:38 +0000 (09:00 -0300)]
perf-tests: add test for removing files.

Without the proposed fix for deletion performance [1], this test is
probably unreasonably slow compared to others at the same
small/medium/large scale.

[1]: id:20210414021627.1236560-3-david@tethera.net

3 years agotest: put shim at end of LD_PRELOAD path
David Bremner [Sat, 13 Mar 2021 12:43:37 +0000 (08:43 -0400)]
test: put shim at end of LD_PRELOAD path

Certain tools like the address-sanitizer fail if they are not the
first LD_PRELOADed library. It does not seem to matter for our shims,
as long as they are loaded before libnotmuch.

3 years agoNEWS: user visible config related changes for 0.32
David Bremner [Sat, 10 Apr 2021 12:49:37 +0000 (09:49 -0300)]
NEWS: user visible config related changes for 0.32

3 years agoCLI: rename notmuch_config_t to notmuch_conffile_t
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.

3 years 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.

3 years 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.

3 years 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.

3 years 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.

3 years 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.

3 years 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.

3 years 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.

3 years 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.

3 years 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.

3 years 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.

3 years 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.

3 years 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)

3 years 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.

3 years 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.

3 years 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.

3 years 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.

3 years 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.

3 years 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.

3 years 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.

3 years 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.

3 years 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.

3 years 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.

3 years 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.

3 years 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.

3 years 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

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

3 years 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 years 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 years 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 years 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.