notmuch
14 months agolib: setup user headers in query parser
David Bremner [Sat, 17 Nov 2018 14:08:59 +0000 (10:08 -0400)]
lib: setup user headers in query parser

These tests will need to be updated if the Xapian
query print/debug format changes.

14 months agocli/config: check syntax of user configured field names
David Bremner [Wed, 27 Mar 2019 10:13:31 +0000 (07:13 -0300)]
cli/config: check syntax of user configured field names

These restrictions are meant to prevent incompatibilities with the
Xapian query parser (which will split at non-word characters) and
clashes with future notmuch builtin fields.

14 months agocli/config: support user header index config
David Bremner [Sat, 17 Nov 2018 14:08:58 +0000 (10:08 -0400)]
cli/config: support user header index config

We don't do anything with this configuration information information
yet, but nonetheless add a couple of regression tests to make sure we
don't break standard functionality when we do use the configuration
information.

14 months agocli/config: refactor _stored_in_db
David Bremner [Sat, 17 Nov 2018 14:08:57 +0000 (10:08 -0400)]
cli/config: refactor _stored_in_db

This will make it easier to add other prefixes that are stored in the
database, compared to special casing each one as "query." was. This
commit also adds the ability to validate keys with a given
prefix. This ability will be used in a future commit.

14 months agoutil: add unicode_word_utf8
David Bremner [Tue, 26 Mar 2019 02:07:24 +0000 (23:07 -0300)]
util: add unicode_word_utf8

This originally use Xapian::Unicode::is_wordchar, but that forces
clients to link directly to libxapian, which seems like it might be
busywork if nothing else.

14 months agoemacs: make notmuch-search-interactive-region obsolete
Leo Vivier [Mon, 20 May 2019 12:21:13 +0000 (14:21 +0200)]
emacs: make notmuch-search-interactive-region obsolete

`notmuch-search-interactive-region' was moved to notmuch-lib.el in
f3cba19f882471a396a6b6175a709ccd1f6f34a0 and renamed to
`notmuch-interactive-region' without making the old function
obsolete, thereby breaking user-commands which made use of it.

This commit marks the function as obsolete and makes it an alias for
the new function.

14 months agon_m_remove_indexed_terms: reduce number of Xapian API calls.
David Bremner [Tue, 16 Apr 2019 01:46:16 +0000 (22:46 -0300)]
n_m_remove_indexed_terms: reduce number of Xapian API calls.

Previously this functioned scanned every term attached to a given
Xapian document. It turns out we know how to read only the terms we
need to preserve (and we might have already done so). This commit
replaces many calls to Xapian::Document::remove_term with one call to
::clear_terms, and a (typically much smaller) number of calls to
::add_term. Roughly speaking this is based on the assumption that most
messages have more text than they have tags.

According to the performance test suite, this yields a roughly 40%
speedup on "notmuch reindex '*'"

14 months agotest-lib.sh: colors to test output when parallel(1) is run on tty
Tomi Ollila [Wed, 8 May 2019 18:51:47 +0000 (21:51 +0300)]
test-lib.sh: colors to test output when parallel(1) is run on tty

Done via $COLORS_WITHOUT_TTY environment variable as passing options
to commands through parallel(1) does not look trivial.

Reorganized color checking in test-lib.sh a bit for this (perhaps
were not fully necessary but rest still an improvement):

  - color checking commands in subshell are not run before arg parsing
    (args may disable colors with --no-color)

  - [ -t 1 ] is checked before forking subshell

14 months agotest-lib.sh: "tidied" emacs_deliver_message ()
Tomi Ollila [Thu, 16 May 2019 20:43:51 +0000 (23:43 +0300)]
test-lib.sh: "tidied" emacs_deliver_message ()

Added initialization and checking of smtp_dummy_port
like it was done with smtp_dummy_pid.

Made those function-local variables.

One 8 spaces to tab consistency conversion.

And last, but definitely not least; while doing above
noticed that there were quite a few double-quoted strings
where $@ was in the middle of it -- replaced those with $*
for robustness ("...$@..." expands params to separate words,
"...$*..." params expands to single word).

14 months agotest: redirect STDIN from /dev/null
Tomi Ollila [Tue, 21 May 2019 20:17:02 +0000 (23:17 +0300)]
test: redirect STDIN from /dev/null

Without this stdin may be anything that parent process provided for it.

Test processes might have tried to read something from it, which would
have caused undeterministic behavior.

E.g. gdb(1) tries to do tty related ioctls on fd 0 (and fd 1 and fd 2,
but those are redirected to 'test.output' before test runs).

14 months agoconfigure: make _check_session_keys work with an as-needed linker
Daniel Kahn Gillmor [Mon, 20 May 2019 20:52:01 +0000 (16:52 -0400)]
configure: make _check_session_keys work with an as-needed linker

When using a promiscuous linker, _check_session_keys was working fine.

But some OSes (including some versions of Ubuntu) have set their
linker to always link in "--as-needed" mode, which means that the
order of the objects linked is relevant.  If a library is loaded
before it is needed, that library will no longer be linked in the
final outcome.  _check_session_keys.c was failing on those systems.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
14 months agoconfigure: handle TEMP_GPG more robustly
Daniel Kahn Gillmor [Mon, 20 May 2019 20:52:00 +0000 (16:52 -0400)]
configure: handle TEMP_GPG more robustly

We never want ./configure to try to do something with an unassigned
variable.  So, make the directory $TEMP_GPG at the start of the
testing of session-key handling, and clean it up afterwards as long as
the directory exists.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
14 months agoconfigure: better error handling on session key check.
Daniel Kahn Gillmor [Mon, 20 May 2019 20:51:59 +0000 (16:51 -0400)]
configure: better error handling on session key check.

There are a few changes bundled here:

 * say "No." explicitly if there's a failure.

 * try to avoid implying that gpgme-config is necessary to build
   notmuch itself (it's not, though it may be useful if you need to
   rebuild gmime).

 * leave _check_session_keys and _check_session_keys.c around if
   ./configure fails, so that the user can play with it more easily
   for debugging.

 * let error messages show when _check_session_keys.c is built.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Amended by DB: use command -v instead of which.

14 months agotest/emacs: revert invalid-from test to pre-86f89385 behaviour
David Bremner [Sun, 12 May 2019 02:45:59 +0000 (20:45 -0600)]
test/emacs: revert invalid-from test to pre-86f89385 behaviour

To the best of my understanding, this original behaviour was what
Carl's homebrew parser produced. With commit 86f89385 Austin switched
to using GMime (2.6). This produced arguably worse results, but since
the input was bad, we could live with it. Now with GMime 3.0 we are
getting the original results again, and there is no reason to consider
this test broken.

14 months agoconfigure: Ensure that GMime can extract session keys
Daniel Kahn Gillmor [Mon, 6 May 2019 20:16:55 +0000 (16:16 -0400)]
configure: Ensure that GMime can extract session keys

GMime 3.0 and higher can extract session keys, but it will *not*
extract session keys if it was built with --disable-crypto, or if it
was built against GPGME version < 1.8.0.

Notmuch currently expects to be able to extract session keys, and
tests will fail if it is not possible, so we ensure that this is the
case during ./configure time.

Part of this feels awkward because notmuch doesn't directly depend on
gpg at all.  Rather, it depends on GMime, and the current
implementation of GMime depends on GPGME for its crypto, and GPGME in
turn depends on gpg.

So the use of gpg in ./configure isn't actually introducing a new
dependency, though if a future version of GMime were ever to move away
from GnuPG, we might need to reconsider.

Note that this changeset depends on
id:20190506174327.13457-1-dkg@fifthhorseman.net , which supplies the
rfc822 message test/corpora/crypto/basic-encrypted.eml used in it.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
14 months agotests: fail and report when a parallel build fails (or times out)
Daniel Kahn Gillmor [Mon, 20 May 2019 17:20:57 +0000 (13:20 -0400)]
tests: fail and report when a parallel build fails (or times out)

When a parallel build fails (or when it times out, if timeout is
present), the test suite should not blithely succeed.  Catch these
failures and at least report them.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
14 months agotests: make timeout configurable with NOTMUCH_TEST_TIMEOUT (default: 2m)
Daniel Kahn Gillmor [Mon, 20 May 2019 17:20:56 +0000 (13:20 -0400)]
tests: make timeout configurable with NOTMUCH_TEST_TIMEOUT (default: 2m)

The current 2 minute timeout is reasonable, but to exercise the test
suite or induce timeout failures, we might want to make it shorter.
This makes it configurable so you can run (for example):

    make check NOTMUCH_TEST_TIMEOUT=10s

We stick with the default of 2m.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
14 months agotest: show what emacs sees of an encrypted message when crypto is disabled
Daniel Kahn Gillmor [Mon, 22 Apr 2019 17:18:13 +0000 (13:18 -0400)]
test: show what emacs sees of an encrypted message when crypto is disabled

Some users may set notmuch-crypto-process-mime to nil, disabling all
crypto use.  We should have a baseline for what that looks like.

14 months agolib/message-file: close stream in destructor
David Bremner [Fri, 10 May 2019 00:23:24 +0000 (21:23 -0300)]
lib/message-file: close stream in destructor

Without this,

$ make time-test OPTIONS=--small

leads to fatal errors from too many open files.

Thanks to st-gourichon-fid for bringing this problem to my attention in IRC.

14 months agotest: avoid unnecessary extraction of the test fingerprint
Daniel Kahn Gillmor [Tue, 7 May 2019 13:01:35 +0000 (09:01 -0400)]
test: avoid unnecessary extraction of the test fingerprint

FINGERPRINT is already exported by add_gnupg_home, so this is
unnecessary.  This change also happens to get rid of the superfluous
check-trustdb spew from the test suite that looked like this:

gpg: checking the trustdb
gpg: marginals needed: 3  completes needed: 1  trust model: pgp
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
14 months agotest: let the OS choose a port for smtp-dummy
David Bremner [Tue, 7 May 2019 10:20:49 +0000 (07:20 -0300)]
test: let the OS choose a port for smtp-dummy

This should avoid potential collisions if we start running multiple
smtp-dummy processes in parallel.

14 months agoemacs: test notmuch-show during message decryption
Daniel Kahn Gillmor [Mon, 6 May 2019 17:43:27 +0000 (13:43 -0400)]
emacs: test notmuch-show during message decryption

We did not have a test showing what message decryption looks like
within notmuch-emacs.  This change gives us a baseline for future work
on the notmuch-emacs interface.

This differs from previous revisions of this patch in that it should
be insensitive to the order in which the local filesystem readdir()s
the underlying maildir.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
14 months agotests: environment variable to specify that tests should be serialized
Jameson Graef Rollins [Mon, 6 May 2019 04:44:09 +0000 (04:44 +0000)]
tests: environment variable to specify that tests should be serialized

If NOTMUCH_TEST_SERIALIZE is non-null all tests will be run in series,
rather than in parallel.

14 months agotests: run all tests in parallel, if available
Jameson Graef Rollins [Sat, 4 May 2019 20:57:43 +0000 (20:57 +0000)]
tests: run all tests in parallel, if available

If either the moreutils or GNU parallel utility are available, run all
tests in parallel.  On my eight core machine this makes for a ~x7
speed-up in the full test suite (1m24s -> 12s).

The design of the test suite makes this parallelization trivial.

14 months agotests: remove entangling corpus index optimization
Jameson Graef Rollins [Sat, 4 May 2019 20:57:43 +0000 (20:57 +0000)]
tests: remove entangling corpus index optimization

The add_email_corpus test utility includes logic that tries to re-use
an index of the corpus if available.  This was seemingly done as an
optimization, so that every test that uses the corpus didn't have to
create it's own index of the corpus.  However, this has the perverse
side effect of entangling tests together, and breaks parallelization.

Forcing each test to do it's own index does increase the overall time
of the test slightly (~6%), but this will be more than made up for in
the next patch that introduces paraellization.

14 months agotests: remove some redundant pre-cleanup of the corpus MAIL_DIR
Jameson Graef Rollins [Sat, 4 May 2019 20:57:45 +0000 (20:57 +0000)]
tests: remove some redundant pre-cleanup of the corpus MAIL_DIR

add_email_corpus itself does an rm -rf $MAIL_DIR, so these are not necessary.

14 months agotest/crypto: add_gnupg_home should have ultimate trust on "its own" key
Daniel Kahn Gillmor [Sat, 4 May 2019 21:33:28 +0000 (17:33 -0400)]
test/crypto: add_gnupg_home should have ultimate trust on "its own" key

The typical use case for gpg is that if you control a secret key, you
mark it with "ultimate" ownertrust.

The opaque --import-ownertrust mechanism is GnuPG's standard mechanism
to set up ultimate ownertrust (the ":6:" means "ultimate", for
whatever reason).

We adjust the test suite to match this change, inverting the sense of
one test: since the default is now that the user ID of the suite's own
key is valid, we change the test to make sure that the user ID is not
emitted when it is *not* valid.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
14 months agotest: simplify user ID handling
Daniel Kahn Gillmor [Sat, 4 May 2019 21:33:27 +0000 (17:33 -0400)]
test: simplify user ID handling

The user ID on the self-test is a little bit clunky-looking.  It also
may end up showing up elsewhere in the test suite.  Centralizing the
user ID in one place should make it easier to handle if it ever
changes, and should make tests easier to read.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
14 months agotest/crypto: clarify the difference between ownertrust and validity
Daniel Kahn Gillmor [Sat, 4 May 2019 21:33:26 +0000 (17:33 -0400)]
test/crypto: clarify the difference between ownertrust and validity

This is a subtle difference, but the output of notmuch shouldn't ever
change based on ownertrust itself -- notmuch is intended to show valid
User IDs, and to avoid showing invalid User IDs.

It so happens that setting ownertrust of a key to ultimate sets all
associated user IDs to "full" validity, so the test is correct, but
just misnamed.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
14 months agoutil/crypto: improve comment
Daniel Kahn Gillmor [Mon, 6 May 2019 19:45:51 +0000 (15:45 -0400)]
util/crypto: improve comment

The comment line here lingers from when we were using some fancy
version checking about session keys.  Correct it to match the current
state.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
14 months agoemacs: drop use of message-default-charset
Daniel Kahn Gillmor [Mon, 22 Apr 2019 20:51:16 +0000 (16:51 -0400)]
emacs: drop use of message-default-charset

Apparently, message-default-charset is deprecated, which causes the
following warning messages during the build:

  In notmuch-maildir-setup-message-for-saving:
  emacs/notmuch-maildir-fcc.el:172:31:Warning: ‘message-default-charset’ is an
      obsolete variable (as of 26.1); The default charset comes from the
      language environment

In discussion with emacs upstream over on
https://debbugs.gnu.org/35370, it appears that we can just drop this
entirely and things should still work with emacs 25.

14 months agoemacs: Move notmuch-search-interactive-region to notmuch-lib as notmuch-interactive...
Pierre Neidhardt [Tue, 9 Apr 2019 16:47:12 +0000 (18:47 +0200)]
emacs: Move notmuch-search-interactive-region to notmuch-lib as notmuch-interactive-region

14 months agotravis: use ppa:notmuch/notmuch
Daniel Kahn Gillmor [Sun, 5 May 2019 22:41:26 +0000 (18:41 -0400)]
travis: use ppa:notmuch/notmuch

https://launchpad.net/~notmuch/+archive/ubuntu/notmuch/+packages
contains backports of gmime and gpgme and related cryptographic tools
to ubuntu xenial.

I tried to do a simple backport of gmime alone, and it failed due to
the older gpgme in xenial, so this setup resolves those problems.

This should allow us to continue to use the Travis continuous
integration build.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
14 months agoMerge tag 0.28.4
David Bremner [Sun, 5 May 2019 19:38:51 +0000 (16:38 -0300)]
Merge tag 0.28.4

No functionality changes merged, since the bug in question was already
fixed on master.

14 months agodebian: changelog for 0.28.4-1 0.28.4 archive/debian/0.28.4-1 debian/0.28.4-1
David Bremner [Sun, 5 May 2019 11:09:30 +0000 (08:09 -0300)]
debian: changelog for 0.28.4-1

14 months agoversion: bump to 0.28.4
David Bremner [Sun, 5 May 2019 11:06:07 +0000 (08:06 -0300)]
version: bump to 0.28.4

14 months agoNEWS: NEWS for 0.28.4
David Bremner [Sun, 5 May 2019 11:04:53 +0000 (08:04 -0300)]
NEWS: NEWS for 0.28.4

14 months agocli/show: avoid empty write to stdout in format_part_raw
David Bremner [Sat, 4 May 2019 22:29:08 +0000 (19:29 -0300)]
cli/show: avoid empty write to stdout in format_part_raw

Previously if the input was exactly a multiple of the internal buffer
size, notmuch would attempt to fwrite nothing to stdout, but still
expected fwrite to return 1, causing a failure that looked like this:

  $ notmuch show --format=raw id:87o96f1cya.fsf@codeaurora.org
    ...entire message shown as expected..
  Error: Write failed
  $ echo $?
  1

To fix the problem don't call fwrite at all when there's nothing to
write.

Amended by db: add some tests of message sizes likely to cause this
problem.

15 months agocli/notmuch-show: support gzipped files
David Bremner [Sun, 24 Mar 2019 03:32:44 +0000 (00:32 -0300)]
cli/notmuch-show: support gzipped files

This drops "file" from mime_node_context and just uses a local
variable. It also uses the new gzip aware utility routines recently
added to util/gmime-extra.c. The use of gzopen / gzfile in addition is
a bit icky, but the choice is between that, and providing yet another
readline implimentation that understands GMime streams.

15 months agolib/message_file: open gzipped files
David Bremner [Sun, 24 Mar 2019 03:32:43 +0000 (00:32 -0300)]
lib/message_file: open gzipped files

Rather than storing the lower level stdio FILE object, we store a
GMime stream. This allows both transparent decompression, and passing
the stream into GMime for parsing. As a side effect, we can let GMime
close the underlying OS stream (indeed, that stream isn't visible here
anymore).

This change is enough to get notmuch-{new,search} working, but there is still
some work required for notmuch-show, to be done in a following commit.

15 months agoutil/gmime-extra: add g_mime_stream_gzfile_{new, open}
David Bremner [Sat, 30 Mar 2019 13:03:01 +0000 (10:03 -0300)]
util/gmime-extra: add g_mime_stream_gzfile_{new, open}

These are usable as standard GMime streams, and transparently
decompress gzipped files.

15 months agotravis: bump gmime depends to 3.0
David Bremner [Fri, 3 May 2019 09:59:23 +0000 (06:59 -0300)]
travis: bump gmime depends to 3.0

This is currently unsatisfiable, but at least the build should fail in
a comprehensible way.

15 months agogmime-cleanup: no longer need to use GMime major version during build
Daniel Kahn Gillmor [Thu, 2 May 2019 13:19:47 +0000 (09:19 -0400)]
gmime-cleanup: no longer need to use GMime major version during build

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
15 months agogmime-cleanup: pass NULL as default GMimeParserOptions
Daniel Kahn Gillmor [Thu, 2 May 2019 13:19:46 +0000 (09:19 -0400)]
gmime-cleanup: pass NULL as default GMimeParserOptions

This is a functional change, not a straight translation, because we
are no longer directly invoking g_mime_parser_options_get_default(),
but the GMime source has indicated that the options parameter for
g_mime_parser_construct_message() is "nullable" since upstream commit
d0ebdd2ea3e6fa635a2a551c846e9bc8b6040353 (which itself precedes GMime
3.0).

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
15 months agogmime-cleanup: pass NULL arguments explicitly where GMime 3.0 expects it
Daniel Kahn Gillmor [Thu, 2 May 2019 13:19:45 +0000 (09:19 -0400)]
gmime-cleanup: pass NULL arguments explicitly where GMime 3.0 expects it

Several GMime 2.6 functions sprouted a change in the argument order in
GMime 3.0.  We had a compatibility layer here to be able to handle
compiling against both GMime 2.6 and 3.0.  Now that we're using 3.0
only, rip out the compatibility layer for those functions with changed
argument lists, and explicitly use the 3.0 argument lists.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
15 months agogmime-cleanup: use GMime 3.0 function names
Daniel Kahn Gillmor [Thu, 2 May 2019 13:19:44 +0000 (09:19 -0400)]
gmime-cleanup: use GMime 3.0 function names

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
15 months agogmime-cleanup: use GMime 3.0 data types
Daniel Kahn Gillmor [Thu, 2 May 2019 13:19:43 +0000 (09:19 -0400)]
gmime-cleanup: use GMime 3.0 data types

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
15 months agogmime-cleanup: drop unused gmime #defines and simplify g_mime_init ()
Daniel Kahn Gillmor [Thu, 2 May 2019 13:19:42 +0000 (09:19 -0400)]
gmime-cleanup: drop unused gmime #defines and simplify g_mime_init ()

Several of these #defines were not actually used in the notmuch
codebase any longer.  And as of GMime 3.0, g_mime_init takes no
arguments, so we can also drop the bogus RFC2047 argument that we were
passing and then #defining away.

signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

15 months agogmime-cleanup: drop all arguments unused in GMime 3
Daniel Kahn Gillmor [Thu, 2 May 2019 13:19:41 +0000 (09:19 -0400)]
gmime-cleanup: drop all arguments unused in GMime 3

This means dropping GMimeCryptoContext and notmuch_config arguments.

All the argument changes are to internal functions, so this is not an
API or ABI break.

We also get to drop the #define for g_mime_3_unused.

signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

15 months agogmime-cleanup: drop g_mime_2_6_unref
Daniel Kahn Gillmor [Thu, 2 May 2019 13:19:40 +0000 (09:19 -0400)]
gmime-cleanup: drop g_mime_2_6_unref

signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

15 months agogmime-cleanup: simplify T355-smime.sh
Daniel Kahn Gillmor [Thu, 2 May 2019 13:19:39 +0000 (09:19 -0400)]
gmime-cleanup: simplify T355-smime.sh

GMime 3.0 and later can handle User ID as expected.

signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

15 months agogmime-cleanup: tests should only care about gmime 3
Daniel Kahn Gillmor [Thu, 2 May 2019 13:19:38 +0000 (09:19 -0400)]
gmime-cleanup: tests should only care about gmime 3

note that "notmuch-show for message with invalid From" is still broken
in T310-emacs.sh.  It would be good to debug what's going on there and
try to get it fixed!

signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

15 months agogmime-cleanup: always support session keys
Daniel Kahn Gillmor [Thu, 2 May 2019 13:19:37 +0000 (09:19 -0400)]
gmime-cleanup: always support session keys

Our minimum version of GMime 3.0 always supports good session key
handling.

signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

15 months agogmime-cleanup: remove obsolete gpg_path configuration option and crypto contexts
Daniel Kahn Gillmor [Thu, 2 May 2019 13:19:36 +0000 (09:19 -0400)]
gmime-cleanup: remove obsolete gpg_path configuration option and crypto contexts

Note that we do keep ignoring the gpg_path configuration option,
though, to avoid breakage of existing installations.  It is ignored
like any other unknown configuration option, but we at least document
that it is ignored so that people who find it in their legacy configs
can know that it's safe to drop.

signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

15 months agogmime-cleanup: remove GMime 2.6 variant codeblocks
Daniel Kahn Gillmor [Thu, 2 May 2019 13:19:35 +0000 (09:19 -0400)]
gmime-cleanup: remove GMime 2.6 variant codeblocks

signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

15 months agogmime-cleanup: drop unused gmime 2.6 content_type from _index_encrypted_mime_part
Daniel Kahn Gillmor [Thu, 2 May 2019 13:19:34 +0000 (09:19 -0400)]
gmime-cleanup: drop unused gmime 2.6 content_type from _index_encrypted_mime_part

In _index_mime_part, we don't need to extract the content-type from
the part until just before we use it, so we also defer it lazily.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
15 months agobuild: drop support for gmime-2.6
David Bremner [Thu, 2 May 2019 13:19:33 +0000 (09:19 -0400)]
build: drop support for gmime-2.6

GMime 3.0 is over 2 years old now, and 2.6 has been deprecated in
notmuch for about 1.5 years.

Comments and documentation no longer need to refer to GMime 2.6, so
clean them all up.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
15 months agoemacs: Make first documentation line distinct for "a" and "x" commands.
Örjan Ekeberg [Fri, 5 Apr 2019 15:35:50 +0000 (17:35 +0200)]
emacs: Make first documentation line distinct for "a" and "x" commands.

Since only the first line of the documentation is shown by the
help command, it is confusing when "x" and "a" seem to have the same
binding in show-mode.  This commit makes the two function documentations
first lines different and (hopefully) clearer.

15 months agocrypto: Avoid pretending to verify signatures on unsigned encrypted mail
Daniel Kahn Gillmor [Sat, 20 Apr 2019 17:02:57 +0000 (13:02 -0400)]
crypto: Avoid pretending to verify signatures on unsigned encrypted mail

Unsigned encrypted mail shows up with a weird empty signature list.
If we successfully decrypted and there was no signature in it, we
should just not show a sigstatus at all.

The documentation for g_mime_decrypt_result_get_signatures says:

    a GMimeSignatureList or NULL if the stream was not signed.

15 months agocli/show: pass the siglist directly to the sigstatus sprinter
Daniel Kahn Gillmor [Sat, 20 Apr 2019 17:51:39 +0000 (13:51 -0400)]
cli/show: pass the siglist directly to the sigstatus sprinter

This makes it easier to reuse format_part_sigstatus_sprinter() when we
have other places that we want to display a signature status.

15 months agotests: move FINGERPRINT definition to add_gnupg_home
Daniel Kahn Gillmor [Sat, 20 Apr 2019 17:40:39 +0000 (13:40 -0400)]
tests: move FINGERPRINT definition to add_gnupg_home

If a test has added a GnuPG homedir, it may well want to know the
fingerprint.  This saves us from having to redefine this magic string
in multiple places when more tests eventually use the GnuPG homedir.

15 months agopython: support relative path in default database
Doan Tran Cong Danh [Fri, 19 Apr 2019 03:56:59 +0000 (10:56 +0700)]
python: support relative path in default database

From notmuch 0.28, notmuch support relative database path in
notmuch-config(1), but python binding haven't taught this yet.

afew denied to work with a perfectly fine notmuch-config due to this.

15 months agoemacs: Add missing type and group to defcustom variable
Örjan Ekeberg [Mon, 15 Apr 2019 13:35:19 +0000 (15:35 +0200)]
emacs: Add missing type and group to defcustom variable

Added the type 'regexp and group 'notmuch-send as properties to the
customizable variable notmuch-mua-attachment-regexp.

15 months agodoc: exclude notmuch-emacs.rst if emacs is not present.
David Bremner [Sun, 21 Apr 2019 23:41:34 +0000 (20:41 -0300)]
doc: exclude notmuch-emacs.rst if emacs is not present.

This will still generate a warning about an excluded document in the
toctree, but it cuts down on the noise quite a lot.

15 months agobuild: only try to build .rsti files if we have emacs and sphinx
David Bremner [Sun, 21 Apr 2019 23:36:43 +0000 (20:36 -0300)]
build: only try to build .rsti files if we have emacs and sphinx

Emacs is needed to build them, and sphinx is needed to use them

15 months agobuild: ignore *.stamp
David Bremner [Sun, 21 Apr 2019 17:10:18 +0000 (14:10 -0300)]
build: ignore *.stamp

The current case is docstring.stamp, but it's likely that others will
arise.

15 months agodoc: use stamp file for html docs
David Bremner [Sun, 21 Apr 2019 17:00:18 +0000 (14:00 -0300)]
doc: use stamp file for html docs

These are less time consuming than the texi docs to rebuild (because
the texi rebuild triggers info rebuild), but still take noticable time.

15 months agodoc: use stamp file to control rebuilding texi
David Bremner [Sun, 21 Apr 2019 16:53:03 +0000 (13:53 -0300)]
doc: use stamp file to control rebuilding texi

Apparently the sphinx-doc texinfo builder is not smart enough to only
rebuild those files where the source has changed.

15 months agoCLI/reindex: fix memory leak
David Bremner [Tue, 16 Apr 2019 01:46:15 +0000 (22:46 -0300)]
CLI/reindex: fix memory leak

Since message is owned by messages, it was held for the entire run of
the program. This in turn means that the Xapian::Document objects are
not freed, and thus one ends up with (effectively) a copy of one's
entire mailstore in memory when running

       notmuch reindex '*'

Thanks to Olly Betts for the patient help debugging, and the
suggestion of a fix.

15 months agolib: add 'body:' field, stop indexing headers twice.
David Bremner [Tue, 19 Mar 2019 00:39:21 +0000 (21:39 -0300)]
lib: add 'body:' field, stop indexing headers twice.

The new `body:` field (in Xapian terms) or prefix (in slightly
sloppier notmuch) terms allows matching terms that occur only in the
body.

Unprefixed query terms should continue to match anywhere (header or
body) in the message.

This follows a suggestion of Olly Betts to use the facility (since
Xapian 1.0.4) to add the same field with multiple prefixes. The double
indexing of previous versions is thus replaced with a query time
expension of unprefixed query terms to the various prefixed
equivalent.

Reindexing will be needed for 'body:' searches to work correctly;
otherwise they will also match messages where the term occur in
headers (demonstrated by the new tests in T530-upgrade.sh)

15 months agoNEWS: deprecate Emacs 24
David Bremner [Thu, 28 Mar 2019 11:31:03 +0000 (08:31 -0300)]
NEWS: deprecate Emacs 24

15 months agotest: add test for checking forwarded messages
Örjan Ekeberg [Fri, 12 Apr 2019 12:01:13 +0000 (14:01 +0200)]
test: add test for checking forwarded messages

Add test of forwarding messages from within emacs.
The first test checks that a references header is properly
added to the new message.  The second test checks that the
send-hook of the forwarding message adds a forwarded-tag
to the original message.

15 months agoemacs: Tag forwarded messages with +forwarded (customizable)
Örjan Ekeberg [Fri, 12 Apr 2019 12:01:12 +0000 (14:01 +0200)]
emacs: Tag forwarded messages with +forwarded (customizable)

Use the buffer-local variable notmuch-message-queued-tag-changes
to change tags when the forwarding message is sent.

15 months agoemacs: Use a buffer-local variable to update tags when sending replies
Örjan Ekeberg [Fri, 12 Apr 2019 12:01:11 +0000 (14:01 +0200)]
emacs: Use a buffer-local variable to update tags when sending replies

Instead of relying on the "In-Reply-To" header, use a buffer-local variable,
notmuch-message-queued-tag-changes, to add and remove tags to affected
messages when the message-send-hook is triggered.

15 months agoemacs: Add References header to forwarded messages
Örjan Ekeberg [Fri, 12 Apr 2019 12:01:10 +0000 (14:01 +0200)]
emacs: Add References header to forwarded messages

Include the message-id of forwarded messages in the new message.
This ensures that the new (forwarding) message is linked to the
same thread as the message being forwarded.

15 months agotravis: add xapian-backports PPA
David Bremner [Sun, 14 Apr 2019 01:28:45 +0000 (22:28 -0300)]
travis: add xapian-backports PPA

We really want to be testing with a more current version of xapian
than that available in Ubuntu Xenial

15 months agoperformance-tests: tests for renamed/copied files in notmuch new
David Bremner [Mon, 1 Apr 2019 10:31:51 +0000 (07:31 -0300)]
performance-tests: tests for renamed/copied files in notmuch new

Several people have observed that this is surprisingly slow, and we
have a proposal to add tagging into this code path, so we want to make
sure it doesn't imply too much of a performance hit.

16 months agoemacs: make editing a message as new include FCC
Léo Gaspard [Mon, 22 Oct 2018 14:44:54 +0000 (23:44 +0900)]
emacs: make editing a message as new include FCC

This changes the meaning of `e` for non-drafts to make it behave
similarly to new messages, which here means add the `FCC` header.

16 months agoFix notmuch-describe-key
Yang Sheng [Sun, 3 Mar 2019 04:35:33 +0000 (23:35 -0500)]
Fix notmuch-describe-key

Fix notmuch-describe-key crashing for the following two cases
1. format-kbd-macro cannot deal with keys like [(32 . 126)], switch to
use key-description instead.
2. if a function in the current keymap is not bounded, it will crash
the whole process. We check if it is bounded and silently skip it to
avoid crashing.

16 months agolib: update commentary about path/folder terms
David Bremner [Wed, 13 Mar 2019 00:47:11 +0000 (21:47 -0300)]
lib: update commentary about path/folder terms

We missed this when we changed to binary fields.

16 months agolib: add clarification about the use of "prefix" in the docs.
David Bremner [Wed, 13 Mar 2019 00:47:10 +0000 (21:47 -0300)]
lib: add clarification about the use of "prefix" in the docs.

16 months agolib: drop comment about only indexing one file.
David Bremner [Wed, 13 Mar 2019 00:47:09 +0000 (21:47 -0300)]
lib: drop comment about only indexing one file.

Although the situation is complicated by the value fields (which are
taken from a single file), this comment is now more false than true.

16 months agodoc: document notmuch new --verbose
Michal Sojka [Fri, 29 Mar 2019 09:48:17 +0000 (10:48 +0100)]
doc: document notmuch new --verbose

16 months agoperformance-test: fix copy-paste error in test description
David Bremner [Fri, 29 Mar 2019 11:26:47 +0000 (08:26 -0300)]
performance-test: fix copy-paste error in test description

16 months agopython: fix set_sort/add_tag_exclude restype/argtypes typos
hydrargyrum [Sat, 30 Mar 2019 09:31:58 +0000 (10:31 +0100)]
python: fix set_sort/add_tag_exclude restype/argtypes typos

16 months agotest: Add emacs attachment check tests.
David Edmondson [Sat, 8 Sep 2018 21:40:41 +0000 (22:40 +0100)]
test: Add emacs attachment check tests.

16 months agoemacs: Optionally check for missing attachments in outgoing messages
David Edmondson [Sat, 8 Sep 2018 21:40:40 +0000 (22:40 +0100)]
emacs: Optionally check for missing attachments in outgoing messages

Query the user if the message text indicates that an attachment is
expected but no MML referencing an attachment is found.

This is not enabled by default - see the documentation for
`notmuch-mua-attachment-check'.

16 months agolib: use phrase search for anything not ending in '*'
David Bremner [Sun, 30 Sep 2018 16:27:55 +0000 (13:27 -0300)]
lib: use phrase search for anything not ending in '*'

Anything that does not look like a wildcard should be safe to
quote. This should fix the problem searching for xapian keywords.

16 months agotest: add two known broken tests searching for xapian keywords
David Bremner [Sun, 30 Sep 2018 16:27:54 +0000 (13:27 -0300)]
test: add two known broken tests searching for xapian keywords

Thanks to plujon for pointing out this problem on IRC. The underlying
issue is that the quotes are stripped before the field processors get
the query string, and the heuristic for putting them back is not quite
right.

16 months agoemacs: Easy access to URLs mentioned in the current message
David Edmondson [Thu, 8 Nov 2018 10:45:08 +0000 (10:45 +0000)]
emacs: Easy access to URLs mentioned in the current message

Add a new binding when looking at messages, B, that prompts with a
list of URLs found in the current message, if any. Open the one that
is selected in a browser.

amended by db: s/--browse-urls/-browse-urls/

16 months agorelease: use xz compression
David Bremner [Tue, 19 Mar 2019 10:08:19 +0000 (07:08 -0300)]
release: use xz compression

This produces tarballs that are roughly 30% smaller.

16 months agobuild: Rename GPG_FILE to DETACHED_SIG_FILE
Daniel Kahn Gillmor [Sat, 23 Mar 2019 12:35:44 +0000 (13:35 +0100)]
build: Rename GPG_FILE to DETACHED_SIG_FILE

This is just a semantic cleanup -- we have multiple files that are
OpenPGP signatures.  And while we're probably making signatures with
GnuPG, they can be verified with any OpenPGP implementation, so "GPG_"
is arguably both not specific enough, and overly-specific.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
16 months agobuild: distribute signed sha256sums
Daniel Kahn Gillmor [Sat, 23 Mar 2019 12:35:43 +0000 (13:35 +0100)]
build: distribute signed sha256sums

Distribute clearsigned sha256sum file in addition to the detached
signature.

Verifies that use the sha256sum ensure that the thing signed includes
the name of the tarball. This defends the verifier by default against
a freeze, rollback, or project substitution attack.

A verifier can use something like the following (as expressed in
bash):

      set -o pipefail
      wget https://notmuchmail.org/releases/notmuch-$VERSION.tar.gz{,.sha256.asc}
      gpgv --keyring ./notmuch-signers.pgp --output - notmuch-$VERSION.tar.gz.sha256.asc | sha256sum -c -

See id:87r2b8w956.fsf@fifthhorseman.net and other messages in that
thread for discussion.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
16 months agobuild: ensure that SHA256_FILE is built
Daniel Kahn Gillmor [Sat, 23 Mar 2019 12:35:42 +0000 (13:35 +0100)]
build: ensure that SHA256_FILE is built

The SHA256_FILE used to be built automatically because of the makefile
dependencies.

Since b8a8dbed91d16299a8768646fb6f18181f31ec40, it isn't getting made
properly, so the release target would fail.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
16 months agodoc: Clean up warnings when building notmuch-emacs docs
Daniel Kahn Gillmor [Sat, 23 Mar 2019 12:51:03 +0000 (13:51 +0100)]
doc: Clean up warnings when building notmuch-emacs docs

Without this change, we see this during the build:

    sphinx-build -b html -d doc/_build/doctrees -q ./doc doc/_build/html
    …/doc/notmuch-emacs.rst:67: WARNING: Unexpected indentation.
    …/doc/notmuch-emacs.rst:165: WARNING: Unexpected indentation.
    …/doc/notmuch-emacs.rst:306: WARNING: Unexpected indentation.

This source change doesn't seem to have any effect on the generated
HTML, at least.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
16 months agodoc/build: use $(MAKE) instead of make
David Bremner [Tue, 19 Mar 2019 23:50:28 +0000 (20:50 -0300)]
doc/build: use $(MAKE) instead of make

This should silence some warnings about the jobserver, but also make
it easier to build the docs where GNU make is called something other
than make.

Based on a patch from aidecoe.

16 months agoAdd a configure flag to disable rpaths
Luis Ressel [Tue, 26 Feb 2019 02:06:49 +0000 (03:06 +0100)]
Add a configure flag to disable rpaths

Better support build environments where our /sbin/ldconfig based
heuristic does not work (e.g. some musl libc based systems).

16 months agobuild: sign tarball instead of sha256sum
David Bremner [Wed, 13 Feb 2019 02:17:03 +0000 (22:17 -0400)]
build: sign tarball instead of sha256sum

Adam Majer pointed out in [1] the way were signing releases was
unusual. Neither Carl nor I could think of a good reason for
explicitely signing the checksum (internally of course that's what GPG
is going anyway).

[1] mid:b3fd556d-c346-7af9-a7a2-13b0f3235071@suse.de

16 months agoutil: make remaining headers includable from C++
David Bremner [Sat, 2 Mar 2019 20:26:06 +0000 (16:26 -0400)]
util: make remaining headers includable from C++

libnotmuch_util.a is supposed to be usable from the library and the
CLI, but much the library is compiled as C++. Add in appropriate
wrapping to prevent symbol mangling. These wrappers already existed in
string-util.h; it seems better to be consistent.

16 months agoPrepend regerror() messages with "regexp error: "
Luis Ressel [Mon, 11 Mar 2019 17:14:49 +0000 (18:14 +0100)]
Prepend regerror() messages with "regexp error: "

The exact error messages returned by regerror() aren't standardized;
relying on them isn't portable. Thus, add a a prefix to make clear that
the subsequent message is a regexp parsing error, and only look for this
prefix in the test suite, ignoring the rest of the message.