notmuch
7 days agotest: aggregate-results updates master
Tomi Ollila [Mon, 17 May 2021 08:11:09 +0000 (11:11 +0300)]
test: aggregate-results updates

notmuch-test will now call aggregate-results.sh with file list
that it compiles based on the test ran, and aggregate-results
will report failure is any of the test files are missing.

With this notmuch-test no longer has to exit in non-parallel
run if some test fail to write its report file -- so it works
as parallel tests in this sense.

Changed test_done() in test-lib.sh write report file in one write(2),
so there is (even) less chance it being partially written. Also,
now it writes 'total' last and aggregate-results.sh expects this
line to exist in all report files for reporting to be successful.

Added 'set -eu' to notmuch-test and modified code to work with
these settings. That makes it harder to get mistakes slipped
into committed code.

9 days agolib/message: use passed database for error handling
David Bremner [Mon, 24 May 2021 00:08:29 +0000 (21:08 -0300)]
lib/message: use passed database for error handling

'message' should always be initialized if we reach here, but in case it
is not, we still want to be able to log an error message.

9 days agolib/{open,message}: make some internal functions static
David Bremner [Mon, 24 May 2021 00:08:28 +0000 (21:08 -0300)]
lib/{open,message}: make some internal functions static

They are not used outside their file, so being extern seems like an oversight

9 days agoemacs: update default mailing list archives for stashing links
Jani Nikula [Fri, 21 May 2021 12:51:26 +0000 (15:51 +0300)]
emacs: update default mailing list archives for stashing links

Gmane web interface is long gone, remove it. Make MARC the new
default. Update LKML to Lore, where it already redirects anyway. Also
add Notmuch web archive.

9 days agotest: add known broken test for indexing RFC822 group names
David Bremner [Wed, 24 Mar 2021 00:24:05 +0000 (21:24 -0300)]
test: add known broken test for indexing RFC822 group names

Austin Clements diagnosed this indexing problem in [1].

[1]: id:20130711215207.GR2214@mit.edu

9 days agoemacs: fix declare-function definitions with related line breaks
Tomi Ollila [Sat, 16 Jan 2021 17:17:09 +0000 (19:17 +0200)]
emacs: fix declare-function definitions with related line breaks

- declare-function notmuch-unthreaded lacked file name
- declare-function notmuch-search had differently named last arg
  - note: check-declare-directory did not complain about that
- declare-function notmuch-search-show-thread without nil
- some functions declared to be in different file than those
  existed ("notmuch" -> "notmuch-lib")

- some related function/declare lines were (/are now) wider than
  80-columns; added line breaks (and proper indentation) there

10 days agoemacs: drop setting mail-user-agent, and document how to set it
David Bremner [Fri, 4 Jun 2021 23:05:31 +0000 (20:05 -0300)]
emacs: drop setting mail-user-agent, and document how to set it

After some discussion [1], I decided it is better to make notmuch users
who rely on this behaviour customize mail-user-agent. This is
consistent with the behaviour of other emacs mail packages.

[1]: id:87k0nuhfrk.fsf@toryanderson.com

11 days agotest: source $NOTMUCH_SRCDIR/test/test-lib-emacs.sh
Tomi Ollila [Sun, 23 May 2021 07:34:43 +0000 (10:34 +0300)]
test: source $NOTMUCH_SRCDIR/test/test-lib-emacs.sh

Sourcing test-lib.sh will cd to TMP_DIRECTORY, so
relative path in $0 will not work in previous version
 . $(dirname "$0")/test-lib-emacs.sh

Now individual test scripts -- e.g. ./test/T310-emacs.sh
will work.

2 weeks agoMerge remote-tracking branch 'origin/release'
David Bremner [Mon, 31 May 2021 23:26:31 +0000 (20:26 -0300)]
Merge remote-tracking branch 'origin/release'

2 weeks agoNEWS/emacs: document changes in 0.32 that affect keybindings. release
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/)
3 weeks agoruby: use notmuch_exclude_t enum
Felipe Contreras [Sat, 1 May 2021 12:04:46 +0000 (07:04 -0500)]
ruby: use notmuch_exclude_t enum

It exists since 2013, let's allow it to be used in Ruby.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
3 weeks agotest: add regression test for large number of deletions
David Bremner [Sat, 24 Apr 2021 23:02:43 +0000 (20:02 -0300)]
test: add regression test for large number of deletions

Prior to 9ad19e4454f there was an unhandled Xapian exception when
reindexing after a large number of deletes.  This test was used for
bisection, and will subsequently serve as a regression test.

3 weeks agoperf-test: add test for reindexing after removal/renaming msgs
David Bremner [Sat, 24 Apr 2021 17:46:18 +0000 (14:46 -0300)]
perf-test: add test for reindexing after removal/renaming msgs

At this point it is a bit tricky to measure the performance increase
from the new message deletion code, since the same commit (9ad19e4)
that improved the performance also seems to have fixed a bug with an
uncaught Xapian exception triggered by this test.

3 weeks agotest: say_color() in one write(2)
Tomi Ollila [Thu, 6 May 2021 14:12:32 +0000 (17:12 +0300)]
test: say_color() in one write(2)

say_color() used to call (builtin) printf (and tput(1) to stdout)
several times, which caused attempts to write messages with color
to have partial content (e.g. escape sequences) often intermixed
with other tests when parallel tests were run.

Now, with all output collected, then written out using one
printf, all strings with color print out correctly
((at least short) write(2)'s appear to write out "atomically").

While at it, used only one tput(1) execution to determine whether
color output works, and made bold/colors/sgr0 to tput(1) their
values once per test.

3 weeks agotest: quiet some extra debugging output
David Bremner [Sun, 16 May 2021 14:10:15 +0000 (11:10 -0300)]
test: quiet some extra debugging output

This output does not cause test failures, but may make it harder to
interpret the output.

3 weeks agotest: ignore debugging messages
David Bremner [Sun, 16 May 2021 12:37:40 +0000 (09:37 -0300)]
test: ignore debugging messages

Previously building with "-DDEBUG" broke the test suite in several places.

3 weeks agolib/thread: add common prefix to debug messages, join lines
David Bremner [Sun, 16 May 2021 14:10:13 +0000 (11:10 -0300)]
lib/thread: add common prefix to debug messages, join lines

This will simplify filtering these message, e.g. in the test suite.

3 weeks agodoc: example command-line option reference
Jani Nikula [Fri, 21 May 2021 20:44:13 +0000 (23:44 +0300)]
doc: example command-line option reference

Example reference to a command-line option using the option role
reference. This creates a hyperlink in html, and the usual boldface
style in man page. This could be used throughout the man pages.

3 weeks agodoc: use program and option directives to document options
Jani Nikula [Fri, 21 May 2021 20:44:12 +0000 (23:44 +0300)]
doc: use program and option directives to document options

Use the program and option directives to document the subcommand
options. This unifies a lot of option documentation throughout.

This also makes it possible to reference options with :option:`--foo`
(within .. program::) or :option:`subcommand --foo` (globally). This
is left for later work.

See https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#directive-program

Note: There is a lot of indentation change, but intentionally there is
no reflow. Using 'git diff -w' or 'git show -w' to ignore white space
changes makes this a very easy change to review.

3 weeks agodoc: use envvar directive and role for environment variables
Jani Nikula [Fri, 21 May 2021 20:44:11 +0000 (23:44 +0300)]
doc: use envvar directive and role for environment variables

Make man1/notmuch.rst the single point of truth for describing notmuch
environment variables. Use the envvar directive for that, and
reference them with the envvar role.

Drive-by cleanup configuration file and hook directory search order
documentation.

3 weeks agodoc: cross-reference notmuch man pages with actual links
Jani Nikula [Fri, 21 May 2021 20:44:10 +0000 (23:44 +0300)]
doc: cross-reference notmuch man pages with actual links

Add internal hyperlink targets for man pages and cross-reference them
using the any role reference. There are a number of alternatives to
accomplish this, but this seems like the combination that retains the
man page section number and the same boldface style in the man pages.

As a bonus, we get sanity checking on the links; for example
notmuch-search-terms.rst had a reference to notmuch-properties(1)
i.e. the wrong section.

The obvious semantic follow-up change would be to only have meaningful
"see also" references instead of having them all everywhere.

3 weeks agotest: replace notmuch_passwd_sanitize() with _libconfig_sanitize()
Tomi Ollila [Sat, 22 May 2021 13:39:57 +0000 (16:39 +0300)]
test: replace notmuch_passwd_sanitize() with _libconfig_sanitize()

notmuch_passwd_sanitize() in test-lib.sh is too generic, it cannot
work in many cases...

The more specific version _libconfig_sanitize() replaces it in
T590-libconfig.sh and the code that uses it is modified to output
the keys (ascending numbers printed in hex) so the sanitizer knows
what to sanitize in which lines...

"@" + fqdn -> "@FQDN" replacement is used as fqdn could
-- in theory -- be substring of 'USERNAME'.

'user -> 'USER_FULL_NAME replacement to work in cases where user
is empty -- as only first ' is replaced that works as expected.

In addition to ".(none)" now also ".localdomain" is filtered from
USERNAME@FQDN.

/dev/fd/{n} is not defined in posix, but it is portable enough
(if it weren't it is easy to fix -- now code looks clearer).

3 weeks agodoc: use manpage role references to external man pages
Jani Nikula [Fri, 21 May 2021 20:44:09 +0000 (23:44 +0300)]
doc: use manpage role references to external man pages

Using manpage role references generates helpful links in html
documentation, while retaining the same boldface style in the man
pages.

The external man page site is configurable. The Debian manpage site
seems like a good fit for Notmuch.

3 weeks agoMerge branch 'release'
David Bremner [Sat, 22 May 2021 12:34:55 +0000 (09:34 -0300)]
Merge branch 'release'

3 weeks agoruby: improve compilation with CFLAGS
Felipe Contreras [Mon, 17 May 2021 05:47:46 +0000 (00:47 -0500)]
ruby: improve compilation with CFLAGS

The ruby MakeMakefile generates a makefile that is suboptimal, which has
CFLAGS like this:

  CFLAGS   = $(CCDLFLAGS) -march=x86-64 -mtune=generic \
    -O2 -pipe -fno-plt -fPIC $(ARCH_FLAG)

This works as long as the user doesn't modify the Makefile.

Certain flags (namely -fPIC) need to be present regardless of what
CFLAGS are specified.

The Makefile should have done this instead:

  CFLAGS = -march=x86-64 -mtune=generic -O2
  override CFLAGS += $(CCDLFLAGS) -pipe -fno-plt -fPIC $(ARCH_FLAG)

Unfortunately they didn't, so we need to workaround their lack of
foresight.

We can simply add the necessary flags in the parent Makefile so everyone
is happy.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
3 weeks 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.

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

3 weeks agoCLI/new: check status of notmuch_message_maildir_flags_to_tags
David Bremner [Sat, 8 May 2021 23:03:28 +0000 (20:03 -0300)]
CLI/new: check status of notmuch_message_maildir_flags_to_tags

This improves error reporting since it prints the specifics of the exception.

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

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

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

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

4 weeks agotest: split emacs functionality to its own file
Felipe Contreras [Sat, 15 May 2021 20:47:44 +0000 (15:47 -0500)]
test: split emacs functionality to its own file

This way it's easier to identify the tests that do require emacs stuff.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
4 weeks agotest: emacs: fix a couple of shellcheck complaints
Felipe Contreras [Sat, 15 May 2021 20:47:43 +0000 (15:47 -0500)]
test: emacs: fix a couple of shellcheck complaints

In test-lib-emacs.sh line 20:
    test_require_external_prereq ${TEST_EMACS} || ret=1
                                 ^-----------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
    test_require_external_prereq "${TEST_EMACS}" || ret=1

In test-lib-emacs.sh line 21:
    test_require_external_prereq ${TEST_EMACSCLIENT} || ret=1
                                 ^-----------------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
    test_require_external_prereq "${TEST_EMACSCLIENT}" || ret=1

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
4 weeks agotest: emacs: check for configured emacs
Felipe Contreras [Sat, 15 May 2021 20:47:42 +0000 (15:47 -0500)]
test: emacs: check for configured emacs

Commit d59d9c81 (test: Make the emacsclient binary user-configurable,
2012-11-27) modified the prereq check for the configured emacsclient,
but we probably want to do the same for emacs itself.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
4 weeks agotest: emacs: simplify missing dependencies check
Felipe Contreras [Sat, 15 May 2021 20:47:41 +0000 (15:47 -0500)]
test: emacs: simplify missing dependencies check

No functional changes.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
4 weeks agotest: more style fixes
Felipe Contreras [Sat, 15 May 2021 20:47:40 +0000 (15:47 -0500)]
test: more style fixes

In order to fit the git coding style.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
4 weeks agotest: trivial style cleanups
Felipe Contreras [Sat, 15 May 2021 20:47:39 +0000 (15:47 -0500)]
test: trivial style cleanups

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
4 weeks agoruby: new notmuch_rb_object_destroy() helper
Felipe Contreras [Sat, 15 May 2021 21:21:03 +0000 (16:21 -0500)]
ruby: new notmuch_rb_object_destroy() helper

The struct used to store the types (rb_data_type_t) contains a "data"
field where we can store whatever we want. I use that field to store a
pointer to the corresponding destroy function. For example
notmuch_rb_database_type contains a pointer to notmuch_database_destroy.

I cast that pointer as a notmuch_status_t (func*)(void *) and call
that function passing the internal object (e.g. notmuch_database_t).

Using the rb_data_type_t data we can call the correct notmuch destroy
function.

Therefore this:

  ret = ((notmuch_status_t (*)(void *)) type->data) (nm_object);

Is effectively the same as this:

  ret = notmuch_database_destroy (database);

The advantage of doing it this way is that much less code is necesary
since each rb_data_type_t has the corresponding destroy function stored
in it.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
4 weeks agoruby: add all data types
Felipe Contreras [Sat, 15 May 2021 21:21:02 +0000 (16:21 -0500)]
ruby: add all data types

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
4 weeks agoruby: move towards more modern RTypedData
Felipe Contreras [Sat, 15 May 2021 21:21:01 +0000 (16:21 -0500)]
ruby: move towards more modern RTypedData

Virtually the whole ruby core moved from RData to RTypeData, let's do so
ourselves too.

Basically the information typically passed through Data_Wrap_Struct is
now stored in a struct rb_data_type_t (mark and free functions). This
has the advantage that more information can be easily added, like the
name of the type, a custom data ponter, and more.

Data_Wrap_Struct is replaced with TypedData_Wrap_Struct, and the
information is stored in a struct rb_data_type_t, rather than passed
as arguments.

Check_Type is replaced with Check_TypedStruct, which is a wrapper for
rb_check_typeddata (with casts).

        #define Check_TypedStruct(v, t)      \
            rb_check_typeddata(RBIMPL_CAST((VALUE)(v)), (t))

We can use rb_check_typeddata directly, just like we use rb_data_object_get
directly.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
4 weeks agoruby: create Data_Wrap_Notmuch_Object helper
Felipe Contreras [Sat, 15 May 2021 21:21:00 +0000 (16:21 -0500)]
ruby: create Data_Wrap_Notmuch_Object helper

This makes the code more maintainable and will help in further patches.

No functional changes.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
4 weeks agoruby: add unlikely hint
Felipe Contreras [Sat, 15 May 2021 21:20:59 +0000 (16:20 -0500)]
ruby: add unlikely hint

The error path is very unlikely.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
4 weeks agoruby: fetch class name in case of error
Felipe Contreras [Sat, 15 May 2021 21:20:58 +0000 (16:20 -0500)]
ruby: fetch class name in case of error

There is not much point in complicating the code for error messages that
can be easily constructed.

Before:

  database closed (RuntimeError)

After:

  Notmuch::Database object destroyed (RuntimeError)

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
4 weeks agoruby: simplify data get helper
Felipe Contreras [Sat, 15 May 2021 21:20:57 +0000 (16:20 -0500)]
ruby: simplify data get helper

Data_Get_Struct is nothing but a macro that calls
rb_data_object_get with a cast (unnecessary in C).

        #define Data_Get_Struct(obj, type, sval) \
            ((sval) = RBIMPL_CAST((type*)rb_data_object_get(obj)))

We can use rb_data_object_get directly, and this way we don't need to
pass the type, which is unnecessary information.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
4 weeks agoMerge branch 'release'
David Bremner [Sat, 15 May 2021 12:10:58 +0000 (09:10 -0300)]
Merge branch 'release'

4 weeks 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

4 weeks 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

4 weeks 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

4 weeks 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

4 weeks 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

4 weeks 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

4 weeks 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.

4 weeks 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

4 weeks agoCLI: add missing file notmuch-client-init
David Bremner [Sat, 15 May 2021 11:14:37 +0000 (08:14 -0300)]
CLI: add missing file notmuch-client-init

This file should have been created in commit 5a8d174f, but wasn't.

4 weeks agoCLI/notmuch: make immutable tables const
David Bremner [Thu, 13 May 2021 00:01:02 +0000 (21:01 -0300)]
CLI/notmuch: make immutable tables const

Let the compiler enforce the immutability.

4 weeks agoCLI: make static message strings const
David Bremner [Wed, 12 May 2021 23:40:23 +0000 (20:40 -0300)]
CLI: make static message strings const

This is both a bit clearer and avoids the possibility of modification.

4 weeks agoCLI/config: make immutable tables const
David Bremner [Wed, 12 May 2021 23:25:59 +0000 (20:25 -0300)]
CLI/config: make immutable tables const

Let the compiler help us catch bugs.

4 weeks agoCLI: centralize initialization in notmuch_client_init
David Bremner [Wed, 12 May 2021 23:22:18 +0000 (20:22 -0300)]
CLI: centralize initialization in notmuch_client_init

Initially make sure gmime_filter_reply initialization is
thread-safe (assuming notmuch_client_init is only called once).
For tidyness, also put talloc initialization in the new function.

4 weeks agolib/message: mark flag2tag as const
David Bremner [Wed, 12 May 2021 01:58:55 +0000 (22:58 -0300)]
lib/message: mark flag2tag as const

This table is intended to be immutable

4 weeks agolib/generate_thread_id: move static buffer to notmuch_database_t
David Bremner [Tue, 11 May 2021 11:08:32 +0000 (08:08 -0300)]
lib/generate_thread_id: move static buffer to notmuch_database_t

Work towards the goal of concurrent access to different Xapian
databases from the same process.

4 weeks agolib: make glib initialization thread-safe
David Bremner [Sun, 9 May 2021 20:33:48 +0000 (17:33 -0300)]
lib: make glib initialization thread-safe

In principle this could be done without depending on C++11 features,
but these features should be available since gcc 4.8.1, and this
localized usage is easy to replace if it turns out to be problematic
for portability.

4 weeks agoruby: improve general data get helper
Felipe Contreras [Tue, 4 May 2021 08:17:42 +0000 (03:17 -0500)]
ruby: improve general data get helper

There's no need to do Check_Type, Data_Get_Struct calls
rb_data_object_get(), which already does that.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
4 weeks agoruby: improve all Data_Get_Notmuch_* helpers
Felipe Contreras [Tue, 4 May 2021 08:17:41 +0000 (03:17 -0500)]
ruby: improve all Data_Get_Notmuch_* helpers

There's no need to repeat the same code over and over.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
4 weeks agoruby: add missing Data_Get_Notmuch helpers
Felipe Contreras [Tue, 4 May 2021 08:17:40 +0000 (03:17 -0500)]
ruby: add missing Data_Get_Notmuch helpers

Apparently commit 5c9e3855 (ruby: Don't barf if an object is destroyed
more than once, 2010-05-26) missed these two.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
4 weeks agoMerge branch 'release'
David Bremner [Wed, 12 May 2021 11:42:28 +0000 (08:42 -0300)]
Merge branch 'release'

4 weeks 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

4 weeks 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.

4 weeks 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
5 weeks agoMerge branch 'release'
David Bremner [Mon, 10 May 2021 14:36:56 +0000 (11:36 -0300)]
Merge branch 'release'

5 weeks 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

5 weeks 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.

5 weeks 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.

5 weeks 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.

5 weeks 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

5 weeks 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.

5 weeks 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.

5 weeks 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.

5 weeks 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.

5 weeks agotest: ruby: simplify output comparison
Felipe Contreras [Sat, 1 May 2021 11:59:23 +0000 (06:59 -0500)]
test: ruby: simplify output comparison

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
5 weeks agotest: ruby: don't use instance variables
Felipe Contreras [Sat, 1 May 2021 11:59:22 +0000 (06:59 -0500)]
test: ruby: don't use instance variables

Local variables are perfectly fine.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
5 weeks agotest: ruby: use much more standard Ruby idioms
Felipe Contreras [Sat, 1 May 2021 11:59:21 +0000 (06:59 -0500)]
test: ruby: use much more standard Ruby idioms

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
6 weeks agotest: ruby: use much more standard puts
Felipe Contreras [Sat, 1 May 2021 11:59:20 +0000 (06:59 -0500)]
test: ruby: use much more standard puts

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
6 weeks agotest: ruby: simplify test_ruby()
Felipe Contreras [Sat, 1 May 2021 11:59:19 +0000 (06:59 -0500)]
test: ruby: simplify test_ruby()

We always do test_expect_equal_file, so do it in test_ruby() directly.

The only subtest where we don't (get non-existent file) can be easily
modified.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
6 weeks agotest: ruby: simplify MAIL_DIR initialization
Felipe Contreras [Sat, 1 May 2021 11:59:18 +0000 (06:59 -0500)]
test: ruby: simplify MAIL_DIR initialization

There's no need to complicate the script passing the MAIL_DIR
environment variable.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
6 weeks agotest: ruby: simplify MAIL_DIR check
Felipe Contreras [Sat, 1 May 2021 11:59:17 +0000 (06:59 -0500)]
test: ruby: simplify MAIL_DIR check

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
6 weeks agotest: ruby: refactor test_ruby()
Felipe Contreras [Sat, 1 May 2021 11:59:16 +0000 (06:59 -0500)]
test: ruby: refactor test_ruby()

There's no point in repeating the same initialization in all the tests.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
6 weeks agotest: move test_ruby() inside the only client
Felipe Contreras [Sat, 1 May 2021 11:59:15 +0000 (06:59 -0500)]
test: move test_ruby() inside the only client

Not much point in polluting the main library, and also will be useful to
modify it in tandem with the tests.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
6 weeks agoMerge tag '0.32'
David Bremner [Sun, 2 May 2021 10:41:42 +0000 (07:41 -0300)]
Merge tag '0.32'

notmuch 0.32 release

6 weeks 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

6 weeks 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

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

6 weeks agotest: add external prereqs to many emacs tests
Felipe Contreras [Sat, 1 May 2021 11:54:16 +0000 (06:54 -0500)]
test: add external prereqs to many emacs tests

The tests fail otherwise.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
6 weeks agotest: add prereqs check in test_emacs_expect_t
Felipe Contreras [Sat, 1 May 2021 11:54:15 +0000 (06:54 -0500)]
test: add prereqs check in test_emacs_expect_t

test_emacs may update the external prereqs, in which case we want to
skip the test rather than fail.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
6 weeks agotest: fix wrong SKIP messages
Felipe Contreras [Sat, 1 May 2021 11:54:14 +0000 (06:54 -0500)]
test: fix wrong SKIP messages

When the external prereqs are updated inside the body of the command
(e.g. test_emacs) the message in test_report_skip_ is wrong: it outputs
the body of the command instead of the subtest name.

We need to pass the same argument we pass to test_skip.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
6 weeks agotest: use correct fqdn in passwd_sanitize()
Felipe Contreras [Sat, 1 May 2021 11:54:13 +0000 (06:54 -0500)]
test: use correct fqdn in passwd_sanitize()

My fqdn is 'natae.localdomain', however, socket.getfqdn() returns
'localhost'.

To fetch the true fqdn we need socket.getaddrinfo().

For more information see: https://stackoverflow.com/a/11580042/10474

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
6 weeks agotest: unset NAME environment variable
Felipe Contreras [Sat, 1 May 2021 11:54:11 +0000 (06:54 -0500)]
test: unset NAME environment variable

Otherwise the output from the tests would be different.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
6 weeks agotest: fix passwd_sanitize()
Felipe Contreras [Sat, 1 May 2021 11:54:10 +0000 (06:54 -0500)]
test: fix passwd_sanitize()

If any of the variables is empty the output is completely messed up,
because replace("", "FOO") puts "FOO" before every single character.

I don't have my full name configured, and this is what I get:

  USER_FULL_NAME=USER_FULL_NAME=USER_FULL_NAME USER_FULL_NAMEsUSER_FULL_NAMEtUSER_FULL_NAMEdUSER_FULL_NAMEoUSER_FULL_NAMEuUSER_FULL_NAMEtUSER_FULL_NAME USER_FULL_NAME=USER_FULL_NAME=USER_FULL_NAME

Let's check for empty strings before doing any replace.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>