CLI: make variable n_requested_db_uuid file scope. 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.
CLI: drop notmuch_config_t from subcommand interface. At this point it is unused in all subcommands.
cli: run uncrustify 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.
CLI/restore: convert to new config framework Switch one configuration check to new n_c_get_bool function, and switch use of config as talloc context to notmuch.
CLI: add (unused) database argument to subcommands. 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.
cli/restore: gzerror() after gzclose_r() is a use after free Calling gzerror() (indirectly via gzerror_str()) after gzclose_r is a use after free, according to zlib's manual. amended by db: tidied commit message
don't pass NULL as second parameter to gzerror Although (as of 1.2.11) zlib checks this parameter before writing to it, the docs don't promise to keep doing so, so be safe.
cli: run uncrustify This is the result of running $ uncrustify --replace --config devel/uncrustify.cfg *.c *.h in the top level source directory
cli: convert notmuch_bool_t to stdbool 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.
cli: use designated initializers for opt desc Several changes at once, just to not have to change the same lines several times over: - Use designated initializers to initialize opt desc arrays. - Only initialize the needed fields. - Remove arg_id (short options) as unused. - Replace opt_type and output_var with several type safe output variables, where the output variable being non-NULL determines the type. Introduce checks to ensure only one is set. The downside is some waste of const space per argument; this could be saved by retaining opt_type and using a union, but that's still pretty verbose. - Fix some variables due to the type safety. Mostly a good thing, but leads to some enums being changed to ints. This is pedantically correct, but somewhat annoying. We could also cast, but that defeats the purpose a bit. - Terminate the opt desc arrays using {}. The output variable type safety and the ability to add new fields for just some output types or arguments are the big wins. For example, if we wanted to add a variable to set when the argument is present, we could do so for just the arguments that need it. Beauty is in the eye of the beholder, but I think this looks nice when defining the arguments, and reduces some of the verbosity we have there.
cli: optionally restore message properties from dump file This somewhat mimics the config line parsing, except there can be arbitrarily many key value pairs, so one more level of looping is required.
Use https instead of http where possible 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.
CLI: optionally restore config data. The default to restore config data seems safest, especially since currently we have no config data to mess up.
cli: add global option "--uuid" 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.
cli: define shared options, use for --help and --version Unfortunately it seems trickier to support --config globally The non-trivial changes are in notmuch.c; most of the other changes consists of blindly inserting two lines into every subcommand.
restore: transparently support gzipped input We rely completely on zlib to do the right thing in detecting gzipped input. Since our dump format is chosen to be 7 bit ascii, this should be fine.
cli: abstract dump file open from the dump command Also expose the dump function to the rest of notmuch. No functional changes, except for slight improvement in error handling.
cli: clean up exit status code returned by the cli commands Apart from the status codes for format mismatches, the non-zero exit status codes have been arbitrary. Make the cli consistently return either EXIT_SUCCESS or EXIT_FAILURE.
cli: move config open/close to main() from subcommands This allows specifying config file as a top level argument to notmuch, and generally makes it possible to override config file options in main(), without having to touch the subcommands. If the config file does not exist, one will be created for the notmuch main command and setup and help subcommands. Help is special in this regard; the config is created just to avoid errors about missing config, but it will not be saved. This also makes notmuch config the talloc context for subcommands.
cli: config: make notmuch_config_open() "is new" parameter input only We now have a notmuch_config_is_new() function to query whether a config was created or not. Change the notmuch_config_open() is_new parameter into boolean create_new to determine whether the function should create a new config if one doesn't exist. This reduces the complexity of the API.