Re: [PATCH 2/4] lib: catch error from closed db in n_m_get_message_id

2020-07-04 Thread David Bremner
Floris Bruynooghe writes: >> - * This function will not return NULL since Notmuch ensures that every >> - * message has a unique message ID, (Notmuch will generate an ID for a >> - * message if the original file does not contain one). >> + * This function will return NULL if triggers an

Re: [RFC PATCH] lib: document new database_open API

2020-07-04 Thread David Bremner
Floris Bruynooghe writes: >> + * >> + * - in the environment variable NOTMUCH_DATABASE, if non-empty >> + * >> + * - by $XDG_DATA_HOME/notmuch/$NOTMUCH_PROFILE where XDG_DATA_HOME >> + * defaults to "$HOME/.local/share" and NOTMUCH_PROFILE defaults to >> + * "default" > > I like the profile

Re: [RFC PATCH] lib: document new database_open API

2020-07-04 Thread Floris Bruynooghe
On Fri 03 Jul 2020 at 10:43 -0300, David Bremner wrote: > Several aspects of this are potentially controversial: > > 1) The use of environment variables as fallback. I understand the > discomfort with having a library function check the environment, but > this seems to be functionality people

Re: [PATCH 2/4] lib: catch error from closed db in n_m_get_message_id

2020-07-04 Thread Floris Bruynooghe
Nice. On Mon 29 Jun 2020 at 22:14 -0300, David Bremner wrote: > diff --git a/lib/notmuch.h b/lib/notmuch.h > index ceb5a018..0dc89547 100644 > --- a/lib/notmuch.h > +++ b/lib/notmuch.h > @@ -1363,9 +1363,8 @@ notmuch_message_get_database (const notmuch_message_t > *message); > * message is

[PATCH 01/11] test: remove unused backup_database calls

2020-07-04 Thread David Bremner
Since these backups are never restored, they should be safe to remove. --- test/T560-lib-error.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index 81500536..5af3eab2 100755 --- a/test/T560-lib-error.sh +++ b/test/T560-lib-error.sh @@

[PATCH 07/11] lib/n_m_g_filename: catch Xapian exceptions, document NULL return

2020-07-04 Thread David Bremner
This is the same machinery as applied for notmuch_message_get_{thread,message}_id --- lib/message.cc | 7 ++- lib/notmuch.h | 2 ++ test/T560-lib-error.sh | 1 - 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/message.cc b/lib/message.cc index

[PATCH 04/11] test: add regression test for n_m_get_header

2020-07-04 Thread David Bremner
This function already catches Xapian exceptions, and we want to make sure it stays that way. --- test/T560-lib-error.sh | 16 1 file changed, 16 insertions(+) diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index 6432faaa..777eb375 100755 ---

Second batch of API cleanup for exception safety.

2020-07-04 Thread David Bremner
This is going to be a bit of a slog, so I'm going to send the patches in batches, rather than waiting until I have one giant series. I'm interested in feedback on the last two patches in particular before I adjust notmuch to use the new API itself. An alternative approach would be treat being a

[PATCH 08/11] test: add known broken test for n_m_get_filenames

2020-07-04 Thread David Bremner
This will be fixed in the next commit --- test/T560-lib-error.sh | 17 + 1 file changed, 17 insertions(+) diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index 57c74a2b..8d9b4cc0 100755 --- a/test/T560-lib-error.sh +++ b/test/T560-lib-error.sh @@ -421,4 +421,21 @@

[PATCH 10/11] test: add known broken for n_m_get_flag on closed db

2020-07-04 Thread David Bremner
Exception caught in next commit. Note that FLAG_GHOST is the only one that triggers the I/O code path. --- test/T560-lib-error.sh | 18 ++ 1 file changed, 18 insertions(+) diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index ce3526a4..68aadcdb 100755 ---

[PATCH 06/11] lib: add known broken test for notmuch_message_get_filename

2020-07-04 Thread David Bremner
This will be fixed in the next commit --- test/T560-lib-error.sh | 17 + 1 file changed, 17 insertions(+) diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index d7caed5a..7555197f 100755 --- a/test/T560-lib-error.sh +++ b/test/T560-lib-error.sh @@ -405,4 +405,21 @@

[PATCH 09/11] lib: catch exceptions in n_m_get_filenames

2020-07-04 Thread David Bremner
This is essentially copied from the change to notmuch_message_get_filename --- lib/message.cc | 7 ++- lib/notmuch.h | 2 ++ test/T560-lib-error.sh | 1 - 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/message.cc b/lib/message.cc index 1a9eaffe..8e43a393

[PATCH 11/11] lib: catch exceptions in n_m_get_flag, provide n_m_get_flag_st

2020-07-04 Thread David Bremner
It's not very nice to return FALSE for an error, so provide notmuch_message_get_flag_st as a migration path. --- lib/message.cc | 33 + lib/notmuch.h | 25 + test/T560-lib-error.sh | 18 +- 3 files changed,

[PATCH 02/11] test: drop use of assert in closed db tests

2020-07-04 Thread David Bremner
Instead of printing the same static string for each test, can replace the assert with something simpler (or at least easier to integrate into the test suite). --- test/T560-lib-error.sh | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/T560-lib-error.sh

[PATCH 03/11] lib/message: use LOG_XAPIAN_EXCEPTION in n_m_get_header

2020-07-04 Thread David Bremner
This is just for consistency, and a small reduction in the amount of boilerplate. --- lib/message.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/message.cc b/lib/message.cc index 3ca7b902..0551a427 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -572,9 +572,7 @@

[PATCH 05/11] lib/n_m_get_replies: doc return, initial regression test

2020-07-04 Thread David Bremner
We need to to set a query and retrieve the threads to meaningfully test this function. --- lib/notmuch.h | 5 - test/T560-lib-error.sh | 18 ++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/notmuch.h b/lib/notmuch.h index 0dc89547..037913f4

Re: [PATCH] emacs: Add notmuch-show-local-dates option

2020-07-04 Thread Tomi Ollila
On Fri, Jul 03 2020, David Bremner wrote: > Daniel Kahn Gillmor writes: > >> But if the sender is in TZ=Europe/Berlin, i would see: >> >> Date: Fri, 03 Jul 2020 13:22:36 -0400 [Fri, 03 Jul 2020 19:22:36 +0200] >> >> (Note that RFC 5322 Date format shows the hour offset, but not the >> actual