aboutsummaryrefslogtreecommitdiff
path: root/notmuch.c
AgeCommit message (Collapse)Author
2023-09-23Pass error message from GLib ini parser to CLIDavid Bremner
The function _notmuch_config_load_from_file is only called in two places in open.cc. Update internal API to match the idiom in open.cc. Adding a newline is needed for consistency with other status strings. Based in part on a patch [1] from Eric Blake. [1]: id:20230906153402.101471-1-eblake@redhat.com
2023-09-23CLI: exit with error when load_config returns an error.David Bremner
For now print a generic error message and exit with error on any non-success code. Previously the code exited, but with exit code zero, leading users / scripts to think the command had succeeded.
2022-07-31notmuch.c: add missing trailing newlines in two error messagesTomi Ollila
Removed duplicate error check (and the message) in 3rd case where the same error message (w/o trailing newline) was present. In case of test/T040-setup.sh, command substitution deletes trailing newlines, so related test there cannot be changed (and therefore could not notice this user experience flaw).
2022-06-13CLI: pass --config to external commands via NOTMUCH_CONFIG.David Bremner
This makes `notmuch --config foo external-subcommand` work consistently with the built in subcommands.
2022-06-13CLI: mention sexp-queries in help topics, alphabetizeDavid Bremner
There does not seem to be an easy way to automate maintaining this list, but new topics are not added very often.
2022-06-13CLI: simplify help commandDavid Bremner
This will allow "notmuch help" to work for arbitrary external commands and for any added non-command topics (such as notmuch-sexp-queries).
2021-10-23CLI: move indexopts variable out of shared options blockDavid Bremner
This reduces the amount of global state. Furthermore, index options can be set (in principle) in several ways, not just in the one function for processing indexing command line options.
2021-09-04CLI: move query syntax to shared optionDavid Bremner
This will allow easy addition of a query syntax option to other subcommands.
2021-09-04CLI: make variable n_requested_db_uuid file scope.David Bremner
It turns out that now that we pass an open database into the subcommands, it is easy to check any requested uuid against the database at the same time as we process the other shared arguments. This results in overall less boilerplate code, as well as making a CLI scope function and variable file scope in notmuch.c.
2021-06-25lib: write talloc report in notmuch_database_destroyDavid Bremner
Since most memory allocation is (ultimately) in the talloc context defined by a notmuch_database_t pointer, this gives a more complete view of memory still allocated at program shutdown. We also change the talloc report in notmuch.c to mode "a" to avoid clobbering the newly reported log.
2021-05-14CLI/notmuch: make immutable tables constDavid Bremner
Let the compiler enforce the immutability.
2021-05-14CLI: centralize initialization in notmuch_client_initDavid Bremner
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-04-06CLI: drop notmuch_config_t from subcommand interface.David Bremner
At this point it is unused in all subcommands.
2021-04-06CLI/config: remove calls to notmuch_config_open from top levelDavid Bremner
This will allow simplifying the subcommand interface. Change the internal API to notmuch_config_open to not tie it to the implementation of subcommands in notmuch.c. It also fixes a previously broken test, since notmuch_config_open does not understand the notion of the empty string as a config file name.
2021-03-27CLI/config: support set/get with split configurationDavid Bremner
There are two small code changes. The main one is to retrieve the possibly updated config file name found during the database opening call. The second change is to allow empty config file names, as a (currently broken) way of specifying that configuration should only be taken from the database.
2021-03-27CLI+lib: detect missing database in split configurations.David Bremner
Eventually we want to do all opening of databases in the top level (main function). This means that detection of missing databases needs to move out of subcommands. It also requires updating the library to use the new NO_DATABASE status code.
2021-03-27CLI/notmuch: switch notmuch_command to notmuch_config_getDavid Bremner
The goal at this point is to remove the dependence on notmuch_config_get_* without breaking any existing functionality. This is a step towards removing notmuch_config_get_* in a future commit.
2021-03-27CLI/config: migrate notmuch_config_open to new configDavid Bremner
notmuch_config_open will be preserved in the medium term for use by the commands that are manipulating the config file directly (config and setup)
2021-03-27CLI/setup: switch to new configuration frameworkDavid Bremner
Most of the changes are the elimination of notmuch_config_t accessor use. We also migrate some of the diagnostics to the top level where we are opening the files in question.
2021-03-27CLI: load merged config at top levelDavid Bremner
This paves the way for the conversion of the remaining subcommands to the new configuration framework.
2021-03-19CLI/show: complete conversion to new configuration framework.David Bremner
In order to open the database in main() for this command, we may need to re-open it in the (possibly less common) case where crypto options require write access.
2021-03-13cli: run uncrustifyuncrustify
This is the result of running $ uncrustify --replace --config devel/uncrustify.cfg *.c *.h in the top level source directory Line breaks were then adjusted manually to keep argc and argv together.
2021-02-06cli/new: convert to new config frameworkDavid Bremner
In addition to the same type of changes as converting other subcommands, add the possibility of creating a database at the top level. It would probably make sense to use this for insert as well.
2021-02-06cli/compact: convert to new configuration frameworkDavid Bremner
Switch to the newly created API function notmuch_database_compact_db, which takes the database opened in main().
2021-02-06cli/tag: convert to new config framework.David Bremner
In addition to changing configuration access, change talloc context for allocation.
2021-02-06CLI/{search,address}: convert to new configuration frameworkDavid Bremner
Since we are already passing a search context around as a kind of parameter block, add a new talloc context to that to replace relying on 'config'. Convert notmuch-search and notmuch-address at the same time, because they share some code. Add a test to make sure we don't break passing configuration as a command line argument.
2021-02-06CLI/reply: convert to new config frameworkDavid Bremner
This is messier than some of the other conversions because the extensive use of 'config' as a talloc context.
2021-02-06cli/reindex: convert new config frameworkDavid Bremner
The only non-trivial part is switching the talloc context for query_string_from args from 'config' to 'notmuch'.
2021-02-06CLI/insert: convert to new config framework.David Bremner
The new talloc context is needed to run the hook at the very end of the function. That in turn is needed so that this process gives up the write lock on the database.
2021-02-06CLI/restore: convert to new config frameworkDavid Bremner
Switch one configuration check to new n_c_get_bool function, and switch use of config as talloc context to notmuch.
2021-02-06cli/dump: convert to new config frameworkDavid Bremner
This conversion is trivial because the only configuration information accessed by dump is that stored in the database (in order to dump it). We do need to be careful to keep the write lock on the database to ensure dump consistency.
2021-02-06CLI/count: switch to new configuration frameworkDavid Bremner
The main effort is changing from the old argv style config list iterators to the new more opaque ones provided by the library (and backed by the database+file config cache).
2021-02-06lib/config: add config values iteratorDavid Bremner
This is intended to avoid duplicating the string splitting and traversal code for all clients of the config API.
2021-02-06CLI: add (unused) database argument to subcommands.David Bremner
This will allow transitioning individual subcommands to the new configuration framework. Eventually when they are all converted we can remove the notmuch_config_t * argument. For now, live with the parameter shadowing in some some subcommands; it will go away when they are converted.
2021-02-06CLI: generalize notmuch_config_mode_tDavid Bremner
The renaming and extra values will make sense when we start to convert subcommands to the new configuration framework. It will also avoid collisions with a new enum for configuration keys to be introduced in a future commit.
2019-06-14cli: run uncrustifyuncrustify
This is the result of running $ uncrustify --replace --config devel/uncrustify.cfg *.c *.h in the top level source directory
2019-06-11append _unused to the expression defined using unused() macroTomi Ollila
This way if variables defined using unused() macro are actually used then code will not compile... - removed unused usage around one argc and one argv since those were used - changed one unused (char *argv[]) to unused (char **argv) to work with modified unused() macro definition
2019-05-03gmime-cleanup: drop unused gmime #defines and simplify g_mime_init ()Daniel Kahn Gillmor
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>
2019-05-03gmime-cleanup: drop all arguments unused in GMime 3Daniel Kahn Gillmor
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>
2019-05-03gmime-cleanup: remove obsolete gpg_path configuration option and crypto contextsDaniel Kahn Gillmor
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>
2018-01-04fix typosDaniel Kahn Gillmor
2017-12-11cli/help,completion: added pointers to notmuch-properties(7)Daniel Kahn Gillmor
2017-12-08crypto: add --decrypt=nostash to avoid stashing session keysDaniel Kahn Gillmor
Here's the configuration choice for people who want a cleartext index, but don't want stashed session keys. Interestingly, this "nostash" decryption policy is actually the same policy that should be used by "notmuch show" and "notmuch reply", since they never modify the index or database when they are invoked with --decrypt. We take advantage of this parallel to tune the behavior of those programs so that we're not requesting session keys from GnuPG during "show" and "reply" that we would then otherwise just throw away.
2017-12-08crypto: new decryption policy "auto"Daniel Kahn Gillmor
This new automatic decryption policy should make it possible to decrypt messages that we have stashed session keys for, without incurring a call to the user's asymmetric keys.
2017-12-08lib: convert notmuch decryption policy to an enumDaniel Kahn Gillmor
Future patches in this series will introduce new policies; this merely readies the way for them. We also convert --try-decrypt to a keyword argument instead of a boolean.
2017-12-08indexopts: change _try_decrypt to _decrypt_policyDaniel Kahn Gillmor
This terminology makes it clearer what's going on at the API layer, and paves the way for future changesets that offer more nuanced decryption policy.
2017-12-08indexing: Change from try_decrypt to decryptDaniel Kahn Gillmor
the command-line interface for indexing (reindex, new, insert) used --try-decrypt; and the configuration records used index.try_decrypt. But by comparison with "show" and "reply", there doesn't seem to be any reason for the "try" prefix. This changeset adjusts the command-line interface and the configuration interface. For the moment, i've left indexopts_{set,get}_try_decrypt alone. The subsequent changeset will address those.
2017-12-07cli/help: give a hint about notmuch-emacs-muaDaniel Kahn Gillmor
"notmuch help" doesn't mention "notmuch-emacs-mua" even though we support it through the try_external_command() mechanism. In addition, "notmuch help emacs-mua" doesn't work, even though we ship the appropriate manpage. This changeset fixes both of these problems.
2017-10-21cli: set up shared command-line arguments for indexingDaniel Kahn Gillmor
We have an indexopts structure for manipulating indexing in different ways, but we also have three command-line invocations that can trigger indexing: new, insert, and reindex. This changeset prepares a common parser that these subcommands can share. Note: if the deprecated crypto.gpg_path configuration option is set to anything other than "gpg", we ignore it (and print a warning on stderr, if built against gmime < 3.0). At the moment, it's just --try-decrypt, but others will likely follow.
2017-10-09cli: convert notmuch_bool_t to stdboolJani Nikula
C99 stdbool turned 18 this year. There really is no reason to use our own, except in the library interface for backward compatibility. Convert the cli and test binaries to stdbool.