Specify the configuration file to use. This overrides any
configuration file specified by ${NOTMUCH\_CONFIG}.
+ ``--uuid=HEX``
+ Enforce that the database UUID (a unique identifier which
+ persists until e.g. the database is compacted)
+ is HEX; exit with an error if it is not. This is useful to
+ detect rollover in modification counts on messages. You can
+ find this UUID using e.g. ``notmuch count --lastmod``
+
All global options except ``--config`` can also be specified after the
-command. For example, ``notmuch subcommand --version`` is equivalent to
-``notmuch --version subcommand``.
+command. For example, ``notmuch subcommand --uuid=HEX`` is
+equivalent to ``notmuch --uuid=HEX subcommand``.
COMMANDS
========
notmuch_bool_t gzip_output);
#include "command-line-arguments.h"
+
+extern char *notmuch_requested_db_uuid;
extern const notmuch_opt_desc_t notmuch_shared_options [];
+void notmuch_exit_if_unmatched_db_uuid (notmuch_database_t *notmuch);
+
void notmuch_process_shared_options (const char* subcommand_name);
int notmuch_minimal_options (const char* subcommand_name,
int argc, char **argv);
if (opt_index < 0)
return EXIT_FAILURE;
+ if (notmuch_requested_db_uuid) {
+ fprintf (stderr, "Error: --uuid not implemented for compact\n");
+ return EXIT_FAILURE;
+ }
+
notmuch_process_shared_options (argv[0]);
if (! quiet)
if (opt_index < 0)
return EXIT_FAILURE;
+ if (notmuch_requested_db_uuid)
+ fprintf (stderr, "Warning: ignoring --uuid=%s\n",
+ notmuch_requested_db_uuid);
+
/* skip at least subcommand argument */
argc-= opt_index;
argv+= opt_index;
NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much))
return EXIT_FAILURE;
+ notmuch_exit_if_unmatched_db_uuid (notmuch);
+
query_str = query_string_from_args (config, argc-opt_index, argv+opt_index);
if (query_str == NULL) {
fprintf (stderr, "Out of memory.\n");
NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much))
return EXIT_FAILURE;
+ notmuch_exit_if_unmatched_db_uuid (notmuch);
+
char *output_file_name = NULL;
int opt_index;
NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much))
return EXIT_FAILURE;
+ notmuch_exit_if_unmatched_db_uuid (notmuch);
+
/* Write the message to the Maildir new directory. */
newpath = maildir_write_new (config, STDIN_FILENO, maildir);
if (! newpath) {
fputs (status_string, stderr);
free (status_string);
}
-
return EXIT_FAILURE;
}
+ notmuch_exit_if_unmatched_db_uuid (notmuch);
+
if (notmuch_database_needs_upgrade (notmuch)) {
time_t now = time (NULL);
struct tm *gm_time = gmtime (&now);
NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much))
return EXIT_FAILURE;
+ notmuch_exit_if_unmatched_db_uuid (notmuch);
+
query = notmuch_query_create (notmuch, query_string);
if (query == NULL) {
fprintf (stderr, "Out of memory\n");
}
notmuch_process_shared_options (argv[0]);
+ notmuch_exit_if_unmatched_db_uuid (notmuch);
+
name_for_error = input_file_name ? input_file_name : "stdin";
if (! accumulate)
return EXIT_FAILURE;
}
+ notmuch_exit_if_unmatched_db_uuid (ctx->notmuch);
+
query_str = query_string_from_args (ctx->notmuch, argc, argv);
if (query_str == NULL) {
fprintf (stderr, "Out of memory.\n");
if (notmuch_minimal_options ("setup", argc, argv) < 0)
return EXIT_FAILURE;
+ if (notmuch_requested_db_uuid)
+ fprintf (stderr, "Warning: ignoring --uuid=%s\n",
+ notmuch_requested_db_uuid);
+
if (notmuch_config_is_new (config))
welcome_message_pre_setup ();
NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much))
return EXIT_FAILURE;
+ notmuch_exit_if_unmatched_db_uuid (notmuch);
+
query = notmuch_query_create (notmuch, query_string);
if (query == NULL) {
fprintf (stderr, "Out of memory\n");
NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much))
return EXIT_FAILURE;
+ notmuch_exit_if_unmatched_db_uuid (notmuch);
+
if (notmuch_config_get_maildir_synchronize_flags (config))
tag_flags |= TAG_FLAG_MAILDIR_SYNC;
_help_for (const char *topic);
static notmuch_bool_t print_version = FALSE, print_help = FALSE;
+char *notmuch_requested_db_uuid = NULL;
const notmuch_opt_desc_t notmuch_shared_options [] = {
{ NOTMUCH_OPT_BOOLEAN, &print_version, "version", 'v', 0 },
{ NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 },
+ { NOTMUCH_OPT_STRING, ¬much_requested_db_uuid, "uuid", 'u', 0 },
{0, 0, 0, 0, 0}
};
}
}
+void
+notmuch_exit_if_unmatched_db_uuid (notmuch_database_t *notmuch)
+{
+ const char *uuid = NULL;
+
+ if (!notmuch_requested_db_uuid)
+ return;
+ IGNORE_RESULT (notmuch_database_get_revision (notmuch, &uuid));
+
+ if (strcmp (notmuch_requested_db_uuid, uuid) != 0){
+ fprintf (stderr, "Error: requested database revision %s does not match %s\n",
+ notmuch_requested_db_uuid, uuid);
+ exit (1);
+ }
+}
+
static void
exec_man (const char *page)
{
after=$(notmuch count --lastmod '*' | cut -f3)
result=$(($before < $after))
test_expect_equal 1 ${result}
+
+notmuch count --lastmod '*' | cut -f2 > UUID
+
+test_expect_success 'search succeeds with correct uuid' \
+ "notmuch search --uuid=$(cat UUID) '*'"
+
+test_expect_success 'uuid works as global option ' \
+ "notmuch --uuid=$(cat UUID) search '*'"
+
+test_expect_code 1 'uuid works as global option II' \
+ "notmuch --uuid=this-is-no-uuid search '*'"
+
+test_expect_code 1 'search fails with incorrect uuid' \
+ "notmuch search --uuid=this-is-no-uuid '*'"
+
+test_expect_success 'show succeeds with correct uuid' \
+ "notmuch show --uuid=$(cat UUID) '*'"
+
+test_expect_code 1 'show fails with incorrect uuid' \
+ "notmuch show --uuid=this-is-no-uuid '*'"
+
+test_expect_success 'tag succeeds with correct uuid' \
+ "notmuch tag --uuid=$(cat UUID) +test '*'"
+
+test_expect_code 1 'tag fails with incorrect uuid' \
+ "notmuch tag --uuid=this-is-no-uuid '*' +test2"
+
test_done
{ 0, 0, 0, 0, 0 }
};
+char *notmuch_requested_db_uuid = NULL;
+
void
notmuch_process_shared_options (unused (const char *dummy))
{