X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch.c;h=ce6c5756c9700af25fa79d3e3f5379b7b9122e2c;hp=9580c3fe1e062b4821b8bd10677aafbd8f5ddc5c;hb=71fae18fba8934186a9a067daa9bcba951eb28b1;hpb=653190bf2a1bed19e9a8dffc437084604261cc26 diff --git a/notmuch.c b/notmuch.c index 9580c3fe..ce6c5756 100644 --- a/notmuch.c +++ b/notmuch.c @@ -47,10 +47,12 @@ static int _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} }; @@ -218,6 +220,22 @@ be supported in the future.\n", notmuch_format_version); } } +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) {