X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-search.c;h=7fdc6acaa2fe90c600899dab91ef0caa02e4d443;hp=a591d45b4c39bbaee8ba55edfb1c9fd91674bfd5;hb=dfe15c0e1b18f4d9ab5d328399e56b3be4a251a5;hpb=a9e0786f72bd01186b58b739986e7ac0680ff7c0 diff --git a/notmuch-search.c b/notmuch-search.c index a591d45b..7fdc6aca 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -248,7 +248,6 @@ do_search_threads (search_context_t *ctx) static notmuch_bool_t is_duplicate (const search_context_t *ctx, const char *name, const char *addr) { - notmuch_bool_t duplicate; char *key; mailbox_t *mailbox; @@ -256,20 +255,20 @@ is_duplicate (const search_context_t *ctx, const char *name, const char *addr) if (! key) return FALSE; - duplicate = g_hash_table_lookup_extended (ctx->addresses, key, NULL, (gpointer)&mailbox); - - if (! duplicate) { - mailbox = talloc (ctx->format, mailbox_t); - mailbox->name = talloc_strdup (mailbox, name); - mailbox->addr = talloc_strdup (mailbox, addr); - mailbox->count = 1; - g_hash_table_insert (ctx->addresses, key, mailbox); - } else { + mailbox = g_hash_table_lookup (ctx->addresses, key); + if (mailbox) { mailbox->count++; talloc_free (key); + return TRUE; } - return duplicate; + mailbox = talloc (ctx->format, mailbox_t); + mailbox->name = talloc_strdup (mailbox, name); + mailbox->addr = talloc_strdup (mailbox, addr); + mailbox->count = 1; + g_hash_table_insert (ctx->addresses, key, mailbox); + + return FALSE; } static void @@ -545,6 +544,7 @@ _notmuch_search_prepare (search_context_t *ctx, notmuch_config_t *config, int ar { char *query_str; unsigned int i; + char *status_string = NULL; switch (ctx->format_sel) { case NOTMUCH_FORMAT_TEXT: @@ -570,9 +570,19 @@ _notmuch_search_prepare (search_context_t *ctx, notmuch_config_t *config, int ar notmuch_exit_if_unsupported_format (); - if (notmuch_database_open (notmuch_config_get_database_path (config), - NOTMUCH_DATABASE_MODE_READ_ONLY, &ctx->notmuch)) + if (notmuch_database_open_verbose ( + notmuch_config_get_database_path (config), + NOTMUCH_DATABASE_MODE_READ_ONLY, &ctx->notmuch, &status_string)) { + + if (status_string) { + fputs (status_string, stderr); + free (status_string); + } + 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) { @@ -672,6 +682,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) { NOTMUCH_OPT_INT, &ctx->limit, "limit", 'L', 0 }, { NOTMUCH_OPT_INT, &ctx->dupe, "duplicate", 'D', 0 }, { NOTMUCH_OPT_INHERIT, (void *) &common_options, NULL, 0, 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -680,6 +691,8 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; + notmuch_process_shared_options (argv[0]); + if (ctx->output != OUTPUT_FILES && ctx->output != OUTPUT_MESSAGES && ctx->dupe != -1) { fprintf (stderr, "Error: --duplicate=N is only supported with --output=files and --output=messages.\n"); @@ -728,6 +741,7 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[]) { "false", NOTMUCH_EXCLUDE_FALSE }, { 0, 0 } } }, { NOTMUCH_OPT_INHERIT, (void *) &common_options, NULL, 0, 0 }, + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -735,6 +749,8 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[]) if (opt_index < 0) return EXIT_FAILURE; + notmuch_process_shared_options (argv[0]); + if (! (ctx->output & (OUTPUT_SENDER | OUTPUT_RECIPIENTS))) ctx->output |= OUTPUT_SENDER;