Commit graph

485 commits

Author SHA1 Message Date
David Bremner
4b0c6fb2f1 Merge branch 'release' 2021-06-25 09:34:29 -03:00
David Bremner
636e03a9ca version: bump to 0.32.2 2021-06-25 09:02:54 -03:00
Felipe Contreras
85ae2bcf56 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>
2021-05-23 09:05:33 -03:00
Felipe Contreras
3dae253c4f 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>
2021-05-22 09:17:21 -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
6d5531da0c version: bump to 0.32.1 2021-05-15 08:59:01 -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
ff5311b098 version: bump to 0.32 2021-05-02 07:00:15 -03:00
David Bremner
bc58b5ad0d version: bump to 0.32~rc2 2021-04-28 07:04:57 -03:00
David Bremner
07a8130483 version: bump to 0.32~rc1 2021-04-24 12:26:09 -03:00
David Bremner
2e6a40ea8c update version to 0.32~rc0 2021-04-24 08:45:54 -03:00
Felipe Contreras
62f03b6ab8 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>
2021-04-18 21:42:43 -03:00
David Bremner
2e39ce6eb5 lib: add NOTMUCH_STATUS_NO_DATABASE
This will allow more precise return values from various open related functions.
2021-03-27 09:26:14 -03:00
David Bremner
4c79a2dabe notmuch 0.31.4 release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEkiyHYXwaY0SiY6fqA0U5G1WqFSEFAmAuVjQACgkQA0U5G1Wq
 FSG6RA//bDdAtsG7QlywGONVX1FOSHxAgppDVRvSDXuluPmGgWvc2T80awbonfT5
 AHy9co41L9484QbOzd29d9Ttu5O39JdQbo+DCAJ6y2vm1M1dLCZw3HXaZGfxoUZo
 9L9Agxg/rYIEso7dAehOs3rGsia46aj2MDCVCUuA4DkVFhkbQ2QidIH+l3VPdYqm
 +1XmuJwyftO7hMifFd9W9ifO9wrBcK9WtJ23feufMhqfBsS0ItLysOhZQx+QdxSj
 7GuA6qX6V7XlIWpdohIOMKmT9tGHMDUo6Qk5m8aSc2XmKAybAXRc+qr0Kg8EpvBF
 1d9SqNptcXQL6rORJxluXR/aCuCb7m8YDgxFVSrFcp/M/twbpDC3WzjmAV+RZpDP
 GBKDH06IGaOMOj9GaYYWCe9loGROzOIT4y04Ckukit0AWpmdbaKnkAkPdrxrMWEu
 a5v5KkkMYT42q0PFU5bDjwvq+8Afmzt7oMO72zXz0mfuFNtFzZCUN/AG9LtHoRfk
 Q2ks/xBppmtCxWRAHVWc7f+Gk1OzI2PLVWnXIe9gxGimSpgT2QPUvZcxLHT/XWD5
 XRrrxtkPjKB1v6tWOFEMPI6WxE1iBzoC9AdG2h48ZP5drlLObcAxhAg5AvHJGJSr
 8D4iSa9cKjHD6qxDSXChzF6BF4aDNhF2Flq9Cs9tZb8nyt+Ix18=
 =mAE/
 -----END PGP SIGNATURE-----

Merge tag '0.31.4'

notmuch 0.31.4 release
2021-02-18 08:47:53 -04:00
David Bremner
2ab95d813c version: update to 0.31.4 2021-02-18 07:17:22 -04:00
Daniel Kahn Gillmor
7061e41cd0 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>
2021-02-15 16:32:31 -04:00
David Bremner
ac67cd84ee lib: introduce notmuch_database_create_with_config
This takes a config path parameter, and can use that to decide the
new database location.
2021-02-06 19:48:34 -04:00
David Bremner
55f5e87096 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.
2021-02-06 19:46:46 -04:00
David Bremner
eea258c0c9 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.
2021-02-06 19:43:11 -04:00
David Bremner
baf1202fbc bindings/notmuch2: add missing crypto error status codes
These are needed so that the later codes line up numerically.
2021-02-06 19:37:50 -04:00
David Bremner
c7596d0e7d version: bump 0.31.3 2020-12-25 11:42:12 -04:00
Johannes Larsen
f01f6405c9 python/notmuch2: fix exclude tag handling
A typo in Database._create_query lost the exclude_tag names during the
string to utf-8 conversion.

Amended by DB: fixed patch format and updated commit message.
2020-12-25 11:25:25 -04:00
David Bremner
6003af14c4 version: bump to 0.31.2 2020-11-08 13:19:07 -04:00
David Bremner
b8a3ed175c update versions 2020-11-08 07:32:10 -04:00
Ralph Seichter
981d5a0168 Rename version to version.txt
Building Notmuch on macOS is known to cause problems because the Notmuch
distribution archive contains two files named "version". These names
clash with the <version> header as defined in C++20. Therefore, the
existing naming will likely become a problem on other platforms as well,
once compilers adopt the new standard.

Signed-off-by: Ralph Seichter <github@seichter.de>
Amended-by: db s/keyword/header/ in commit message.
2020-10-30 16:14:24 -03:00
David Bremner
008b8b0574 version: bump to 0.31 2020-09-05 21:26:36 -03:00
David Bremner
c8c0304d77 version: bump to 0.31~rc2 2020-08-29 09:32:36 -03:00
David Bremner
e6f95910b3 version: bump to 0.31~rc1 2020-08-17 21:02:30 -03:00
David Bremner
efb135bed1 version: bump to 0.31~rc0
Start the release process for 0.31
2020-08-16 11:06:13 -03:00
Jonas Bernoulli
6c84dee531 Fix typos 2020-08-09 21:14:36 -03:00
Jonas Bernoulli
c454135376 emacs: Use makefile-gmake-mode in Makefile*s
Use `makefile-gmake-mode' instead of `makefile-mode' because the
former also highlights ifdef et al. while the latter does not.

"./Makefile.global" and one "Makefile.local" failed to specify any
major mode at all but doing so is necessary because Emacs does not
automatically figure out that these are Makefiles (of any flavor).
2020-08-09 21:14:36 -03:00
David Bremner
49d630d0f3 bindings/ruby: replacy use of deprecated notmuch_message_get_flag
Depending on the flag, this actually can return an errror, so raise a
ruby exception if so.
2020-07-18 11:03:29 -03:00
David Bremner
e56a207ce1 version: set to 0.30 2020-07-10 22:21:19 -03:00
David Bremner
038b3e7c30 version: bump to 0.30~rc3 2020-07-03 06:45:17 -03:00
David Bremner
3a42abb456 bindings/python-cffi: copy version file into bindings dir
Attempt to avoid breaking "pip install ."

As far as I can tell, we need to have a copy (not just a relative
symlink) of the version file.
2020-07-03 06:38:55 -03:00
Floris Bruynooghe
81057164cd python-cffi: read version from notmuch version file
This keeps it in sync with the main notmuch version which is less
confusing to users.
2020-06-19 07:01:13 -03:00
David Bremner
cda6e4d104 version: update to 0.30~rc2 2020-06-16 08:29:39 -03:00
Floris Bruynooghe
776a54a0e4 Support aborting the atomic context
Since it is possible to use an atomic context to abort a number of
changes support this usage.  Because the only way to actually abort
the transaction is to close the database this must also do so.

Amended by db: Note the limitation requiring close is a limitation of
the underlying notmuch API, which should be fixed in a future notmuch
release.
2020-06-16 08:17:39 -03:00
Floris Bruynooghe
2d895a0119 Make messages returned by Thread objects owned
This reverses the logic of StandaloneMessage to instead create a
OwnedMessage.  Only the Thread class allows retrieving messages more
then once so it can explicitly create such messages.

The added test fails with SIGABRT without the fix for the message
re-use in threads being present.
2020-06-16 08:02:02 -03:00
Anton Khirnov
1317579079 python/notmuch2: do not destroy messages owned by a query
Any messages retrieved from a query - either directly via
search_messages() or indirectly via thread objects - are owned by that
query. Retrieving the same message (i.e. corresponding to the same
message ID / database object) several times will always yield the same
C object.

The caller is allowed to destroy message objects owned by a query before
the query itself - which can save memory for long-lived queries.
However, that message must then never be retrieved again from that
query.

The python-notmuch2 bindings will currently destroy every message object
in Message._destroy(), which will lead to an invalid free if the same
message is then retrieved again. E.g. the following python program leads
to libtalloc abort()ing:

import notmuch2
db   = notmuch2.Database(mode = notmuch2.Database.MODE.READ_ONLY)
t    = next(db.threads('*'))
msgs = list(zip(t.toplevel(), t.toplevel()))
msgs = list(zip(t.toplevel(), t.toplevel()))

Fix this issue by creating a subclass of Message, which is used for
"standalone" message which have to be freed by the caller. Message class
is then used only for messages descended from a query, which do not need
to be freed by the caller.
2020-06-16 08:02:02 -03:00
Floris Bruynooghe
1bca41698a python config access: fix style and KeyError bug
This fixes some minor style/pep8 things and adds tests for the new
config support.  Also fixes a bug where KeyError was never raised
on a missing key.
2020-06-15 21:50:03 -03:00