- _notmuch_string_map_append (notmuch->config,
- notmuch_config_list_key (list),
- notmuch_config_list_value (list));
+ const char *key = notmuch_config_list_key (list);
+ char *normalized_val = NULL;
+
+ /* If we opened from a given path, do not overwrite it */
+ if (strcmp (key, "database.path") == 0 &&
+ (notmuch->params & NOTMUCH_PARAM_DATABASE) &&
+ notmuch->xapian_db)
+ continue;
+
+ normalized_val = _expand_path (list, key, notmuch_config_list_value (list));
+ _notmuch_string_map_append (notmuch->config, key, normalized_val);
+ talloc_free (normalized_val);