Commit graph

7024 commits

Author SHA1 Message Date
Felipe Contreras
4561f694e9 test: more style fixes
In order to fit the git coding style.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17 07:28:01 -03:00
Felipe Contreras
645bea13cb test: trivial style cleanups
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17 07:27:52 -03:00
Felipe Contreras
5f49e3421f 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>
2021-05-17 07:25:14 -03:00
Felipe Contreras
9574fb6099 ruby: add all data types
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17 07:25:14 -03:00
Felipe Contreras
fba9774a81 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>
2021-05-17 07:25:14 -03:00
Felipe Contreras
12c36a5e3f 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>
2021-05-17 07:25:14 -03:00
Felipe Contreras
682479592b ruby: add unlikely hint
The error path is very unlikely.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17 07:25:14 -03:00
Felipe Contreras
79bb82c217 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>
2021-05-17 07:25:14 -03:00
Felipe Contreras
78c059a24c 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>
2021-05-17 07:25:14 -03:00
David Bremner
c84ccb70f3 Merge branch 'release' 2021-05-15 09:10:58 -03:00
David Bremner
b580009e2b NEWS: finalize release date 2021-05-15 09:04:24 -03:00
David Bremner
57c62c3aeb debian: changelog for 0.32.1-1 2021-05-15 09:03:19 -03:00
David Bremner
6d5531da0c version: bump to 0.32.1 2021-05-15 08:59:01 -03:00
David Bremner
44881fa53e NEWS: add news for $HOME/mail fix 2021-05-15 08:56:46 -03:00
David Bremner
b3258244c8 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
2021-05-15 08:40:05 -03:00
David Bremner
0e8795b28c NEWS: add NEWS for notmuch-{before,after}-tag-hook fixes 2021-05-15 08:38:23 -03:00
Kyle Meyer
319dcfb50e 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.
2021-05-15 08:34:28 -03:00
David Bremner
a663783343 test: add known broken tests for notuch-{before,after}-tag-hook
These tests illustrate the bug reported in id:87v97ytd2s.fsf@fastmail.fm
2021-05-15 08:31:00 -03:00
David Bremner
ccd2ef3871 CLI: add missing file notmuch-client-init
This file should have been created in commit 5a8d174f, but wasn't.
2021-05-15 08:14:37 -03:00
David Bremner
121f9ddad3 CLI/notmuch: make immutable tables const
Let the compiler enforce the immutability.
2021-05-14 06:44:00 -03:00
David Bremner
0c6569d97c CLI: make static message strings const
This is both a bit clearer and avoids the possibility of modification.
2021-05-14 06:42:55 -03:00
David Bremner
19983fe554 CLI/config: make immutable tables const
Let the compiler help us catch bugs.
2021-05-14 06:41:51 -03:00
David Bremner
5a8d174f67 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.
2021-05-14 06:40:37 -03:00
David Bremner
b1b6798588 lib/message: mark flag2tag as const
This table is intended to be immutable
2021-05-14 06:39:12 -03:00
David Bremner
929386fad9 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.
2021-05-14 06:38:19 -03:00
David Bremner
8410be8e08 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.
2021-05-13 22:21:57 -03:00
Felipe Contreras
a34d7b4144 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>
2021-05-12 19:13:31 -03:00
Felipe Contreras
2e57ffb860 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>
2021-05-12 19:13:12 -03:00
Felipe Contreras
75738758f9 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>
2021-05-12 19:13:02 -03:00
David Bremner
25da4a1340 Merge branch 'release' 2021-05-12 08:42:28 -03:00
David Bremner
267365b711 NEWS: add note about fix to notmuch_database_reopen 2021-05-12 08:40:13 -03:00
David Bremner
393c92b042 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.
2021-05-12 08:40:04 -03:00
Michael J Gruber
0729c4e81f 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
2021-05-12 08:34:34 -03:00
David Bremner
b4a4ed0df9 Merge branch 'release' 2021-05-10 11:36:56 -03:00
David Bremner
5ebbf17242 NEWS: start NEWS for 0.32.1 2021-05-10 11:14:57 -03:00
David Bremner
bfbe2e55f2 doc: document database.backup_dir
Most users will not need to change this, but documenting it helps
preserve the interface.
2021-05-10 11:14:57 -03:00
David Bremner
a7de593f72 doc: document (tersely) the intended behaviour of relative paths. 2021-05-10 11:14:57 -03:00
David Bremner
8bf3311084 test: test explicit configuration of backup directory
Including the relative path that was broken until a recent commit.
2021-05-10 11:13:07 -03:00
David Bremner
891b950219 test: test relative paths for database.hook_dir 2021-05-10 11:13:07 -03:00
David Bremner
1040e7aa07 lib/config: expand relative paths when reading from database
This makes the treatment of relative paths consistent between the
database and config files.
2021-05-10 11:12:58 -03:00
David Bremner
322a492c77 test: add known broken test for relative setting of mail_root
The behaviour should not change depending on where the configuration
is stored.
2021-05-10 11:11:42 -03:00
David Bremner
31098c4ae4 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.
2021-05-10 11:08:18 -03:00
David Bremner
ef0b126619 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.
2021-05-10 11:06:40 -03:00
Felipe Contreras
ac64de450a test: ruby: simplify output comparison
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-05 17:00:37 -03:00
Felipe Contreras
faf5511c3e test: ruby: don't use instance variables
Local variables are perfectly fine.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-05 17:00:16 -03:00
Felipe Contreras
c4b23cf29a test: ruby: use much more standard Ruby idioms
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-05 16:40:15 -03:00
Felipe Contreras
63413a5563 test: ruby: use much more standard puts
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-02 08:12:15 -03:00
Felipe Contreras
2dbc5fdf5a 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>
2021-05-02 08:12:05 -03:00
Felipe Contreras
9f6bc01824 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>
2021-05-02 08:11:56 -03:00
Felipe Contreras
c1b99d6f94 test: ruby: simplify MAIL_DIR check
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-02 08:11:42 -03:00