aboutsummaryrefslogtreecommitdiff
path: root/notmuch-config.c
AgeCommit message (Collapse)Author
2024-07-25CLI: update commentary in config file to better match codeDavid Bremner
This comment has been out of date since notmuch 0.32. Although it isn't really possible to explain all the options here, explain both one new "split" way of doing things and the traditional one with database inside $MAIL_ROOT/.notmuch.
2023-08-21CLI/config: simulate top level comments when creating configDavid Bremner
According to discussion on https://gitlab.gnome.org/GNOME/glib/-/issues/3078 it looks like upstream will stop supporting top of file comments. It is questionable whether we really need this feature, but for now update notmuch-config to simulate it.
2022-01-24CLI/setup: special case single item listsDavid Bremner
This matches the heuristic used by "notmuch config set" to decide if something is a list. This change fixes the bug reported at [1]. [1]: id:6O3LTUhoXlrnkPWCtPJCP4cagU7mFVEdyTpcC_37BoSzStlARXDBa7oczy6hB0jyjGjBQvgj_jFV58cw0aNx-jUg1h1O-FQ7820k68C0X4M=@protonmail.com
2021-12-03rename built_with.sexpr_query to built_with.sexp_queriesDavid Bremner
It is confusing to use two different names (sexp vs sexpr) when compared with the command line option --query=sexp and (furthermore) singular vs plural when compared with the man page title.
2021-09-04CLI/config support saving s-expression queriesDavid Bremner
This commit does not enable using saved s-expression queries, only saving and retrieving them from the config file or the database. Use in queries will be enabled in a following commit.
2021-09-04configure: optional library sfsexpDavid Bremner
The configure part is essentially the same as the other checks using pkg-config. Since the optional inclusion of this feature changes what options are available to the user, include it in the "built_with" pseudo-configuration keys.
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-08-18Merge tag 'debian/0.32.3-1'David Bremner
notmuch release 0.32.3-1 for unstable (sid) [dgit] [dgit distro=debian no-split --quilt=linear]
2021-08-17CLI/config: restore "notmuch config get built_with.*"David Bremner
We need to special case the config section "built_with" because it is not (currently) handled by the library. This seems consist with the other sub-sub-commands 'list' and 'set'.
2021-05-14CLI/config: make immutable tables constDavid Bremner
Let the compiler help us catch bugs.
2021-04-24compat: rename {,notmuch_}canonicalize_file_nameĐoàn Trần Công Danh
When compat canonicalize_file_name was introduced, it was limited to C code only because it was used by C code only during that time. >From 5ec6fd4d, (lib/open: check for split configuration when creating database., 2021-02-16), lib/open.cc, which is C++, relies on the existent of canonicalize_file_name. However, we can't blindly enable canonicalize_file_name for C++ code, because different implementation has different additional signature for C++ and users can arbitrarily add -DHAVE_CANONICALIZE_FILE_NAME=0 to {C,CXX}FLAGS. Let's move our implementation into a util library. Helped-by: Tomi Ollila <tomi.ollila@iki.fi> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
2021-04-06CLI: rename notmuch_config_t to notmuch_conffile_tDavid Bremner
The name is a compromise between keeping function names from getting too long, and avoiding confusion with the newer notmuch_config library API. Try to make clear that the residual functionality is only about updating configuration files.
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: default to storing all config in external filesDavid Bremner
Previously the fact that some configuration options were only stored in the database (and thus editing the config file had no effect) was a source of user confusion. This was fixed with the series ending at d9af0af1646. On the other hand, the underlying partition of config options into those stored by default in the database and those stored in the config file remained. This is also confusing, since now some invocations of "notmuch config set" modify the config file, and others silently modify the database instead. With this commit, it is up to the user to decide which configuration to modify. A new "--database" option is provided for notmuch config to enable modifying the configuration information in the database; otherwise the default is to update an external config file.
2021-03-27CLI/config: drop cached data from notmuch_config_tDavid Bremner
The idea is to preserve notmuch_config_t as a thin wrapper for GKeyFile.
2021-03-27CLI/config: drop obsolete notmuch_config_get_*David Bremner
These are no longer used, replaced by notmuch_config_get.
2021-03-27CLI/config: use notmuch_database_reopenDavid Bremner
This allows `notmuch config` to use the common configuration information carried by the notmuch_database_t opened at the top level.
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/config: switch "notmuch config list" to merged configDavid Bremner
Use the database opened at the top level rather than opening another notmuch_database_t. Test output changes because keys are now listed in alphabetical order, and because a missing database is no longer an error.
2021-03-27CLI/config: use merged config for "config get"David Bremner
This commit starts the conversion of notmuch-config.c functionality (as opposed to just interface) to the new config framework. The change to T030-config is because of the move of the canonicalization database paths from the notmuch_config_t accessor to the internal function _choose_database_path.
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/config: add accessor for config file nameDavid Bremner
This is intended for use in temporary code transitioning to the new configuration system. The name is chosen to avoid cluttering the notmuch_config_* namespace further with non-library functions.
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.
2020-02-19Drop deprecated/unused crypto.gpg_pathDaniel Kahn Gillmor
crypto.gpg_path was only used when we built against gmime versions before 3.0. Since we now depend on gmime 3.0.3 or later, it is meaningless. The removal of the field from the _notmuch_config struct would be an ABI change if that struct were externally exposed, but it is not, so it's safe to unilaterally remove it. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
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-14cli: partial whitespace cleanup in notmuch-config.cDavid Bremner
This avoids spurious tab to space conversion by uncrustify
2019-05-25cli/config: check syntax of user configured field namesDavid Bremner
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.
2019-05-25cli/config: support user header index configDavid Bremner
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.
2019-05-25cli/config: refactor _stored_in_dbDavid Bremner
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.
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-09-08notmuch: Database paths without a leading / are relative to $HOMEDavid Edmondson
If the database path specified in the configuration file does *not* start with a /, presume that it is relative to $HOME and modify the path used to open the database accordingly.
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-10-21config: define new option index.try_decryptDaniel Kahn Gillmor
By default, notmuch won't try to decrypt on indexing. With this patch, we make it possible to indicate a per-database preference using the config variable "index.try_decrypt", which by default will be false. At indexing time, the database needs some way to know its internal defaults for how to index encrypted parts. It shouldn't be contingent on an external config file (since that can't be retrieved from the database object itself), so we store it in the database. This behaves similarly to the query.* configurations, which are also stored in the database itself, so we're not introducing any new dependencies by requiring that it be stored in the database.
2017-10-21config: test whether an item is stored in the database by nameDaniel Kahn Gillmor
QUERY_STRING was only used in two places, both to test whether a variable should be stored in (or retrieved from) the database. Since other configuration variables might be stored in the database in the future, consolidate that test into a single function. We also document that these configuration options should not be placed in the config file.
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.
2017-07-14config: deprecate/drop crypto.gpg_path under gmime 2.6/3.0Daniel Kahn Gillmor
gmime 3.0 no longer offers a means to set the path for gpg. Users can set $PATH anyway if they want to pick a differently-installed gpg (e.g. /usr/local/bin/gpg), so this isn't much of a reduction in functionality. The one main difference is for people who have tried to use "gpg2" to make use of gpg 2.1, but that isn't usefully co-installable anyway.
2017-02-28notmuch-config: ENOENT vs generic handling when file open fails.Tomi Ollila
When opening configuration file fails, ENOENT (file not found) is handled specially -- in setup missing file is ok (often expected), and otherwise user can be informed to run notmuch setup. In any other case the the reason is unknown, so there is no other option but to print generic error message to stderr.
2017-02-28cli/config: don't try to open config file for 'notmuch help'Jani Nikula
The help command does not really need to try to open the config file. So don't.
2017-01-07cli/config: rename name to key in _config_set_listJani Nikula
The other getters and setters speak of key, follow suit. No functional changes.
2017-01-07cli/config: allocate config using talloc_zeroJani Nikula
Do not initialize each field separately. It's more robust to allocate the config with zero initialization, and only set the non-zero defaults individually.
2016-12-16notmuch-config: replace config reading functionIoan-Adrian Ratiu
Config files are currently read using glib's g_key_file_load_from_file function which is very inconvenient because it's limited by design to read only from "regular data files" in a filesystem. Because of this limitation notmuch can't read configs from pipes, fifos, sockets, stdin, etc. Not even "notmuch --config=/dev/stdin" works: Error reading configuration file /dev/stdin: Not a regular file So replace g_key_file_load_from_file with g_key_file_load_from_data which gives us much more freedom to read configs from multiple sources. This also helps the more security sensitive users: If someone has private information in the config file, it can be encrypted on disk, then decrypted in RAM and passed through a pipe directly to notmuch without the use of intermediate plain text files. Signed-off-by: Ioan-Adrian Ratiu <adi@adirat.com>
2016-12-16cli: abstract config file reading to a separate functionJani Nikula
Simplify and fix the coding style while at it.
2016-06-29lib: add built_with handling for XAPIAN_DB_RETRY_LOCKDavid Bremner
This support will be present only if the appropriate version of xapian is available _and_ the user did not disable the feature when building. So there really needs to be some way for the user to check.
2016-06-05Use https instead of http where possibleDaniel Kahn Gillmor
Many of the external links found in the notmuch source can be resolved using https instead of http. This changeset addresses as many as i could find, without touching the e-mail corpus or expected outputs found in tests.
2016-05-25CLI: add notmuch-config support for named queriesDavid Bremner
Most of the infrastructure here is general, only the validation/dispatch is hardcoded to a particular prefix. A notable change in behaviour is that notmuch-config now opens the database e.g. on every call to list, which fails with an error message if the database doesn't exit yet.
2016-05-13lib/cli: add library API / CLI for compile time optionsDavid Bremner
This is intentionally low tech; if we have more than two options it may make sense to build up what infrastructure is provided.
2015-08-14cli: add global option "--uuid"David Bremner
The function notmuch_exit_if_unmatched_db_uuid is split from notmuch_process_shared_options because it needs an open notmuch database. There are two exceptional cases in uuid handling. 1) notmuch config and notmuch setup don't currently open the database, so it doesn't make sense to check the UUID. 2) notmuch compact opens the database inside the library, so we either need to open the database just to check uuid, or change the API.
2015-06-01cli: add standard option processing to config, help and setupDavid Bremner
In particular this fixes a recently encountered bug where the "--config" argument to "notmuch setup" is silently ignored, which the unpleasant consequence of overwriting the users config file.