Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 46930431FCB for ; Sat, 22 Mar 2014 19:26:43 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yW2CJFI7qJti for ; Sat, 22 Mar 2014 19:26:36 -0700 (PDT) Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 75538431FC0 for ; Sat, 22 Mar 2014 19:26:36 -0700 (PDT) Received: from remotemail by yantan.tethera.net with local (Exim 4.80) (envelope-from ) id 1WRY7N-0008Oz-W3; Sat, 22 Mar 2014 23:26:33 -0300 Received: (nullmailer pid 2938 invoked by uid 1000); Sun, 23 Mar 2014 02:26:26 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 1/2] config: add key database.upgrades Date: Sat, 22 Mar 2014 23:26:12 -0300 Message-Id: <1395541573-2417-2-git-send-email-david@tethera.net> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1395541573-2417-1-git-send-email-david@tethera.net> References: <87bnx4jyyp.fsf@servo.finestructure.net> <1395541573-2417-1-git-send-email-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Mar 2014 02:26:43 -0000 The intent is to allow the user to enable or disable automatic database upgrades. This doesn't do anything yet. --- doc/man1/notmuch-config.rst | 4 ++++ notmuch-client.h | 7 +++++++ notmuch-config.c | 34 +++++++++++++++++++++++++++++----- test/T030-config.sh | 1 + test/T040-setup.sh | 1 + 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst index 3c9a568..fc7fab6 100644 --- a/doc/man1/notmuch-config.rst +++ b/doc/man1/notmuch-config.rst @@ -49,6 +49,10 @@ The available configuration items are described below. within a sub-directory of the path configured here named ``.notmuch``. + **database.upgrades** + Set to ``yes`` to enable automatic in-place upgrades of the notmuch + database. + **user.name** Your full name. diff --git a/notmuch-client.h b/notmuch-client.h index 278b498..3891a82 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -275,6 +275,13 @@ notmuch_config_set_database_path (notmuch_config_t *config, const char *database_path); const char * +notmuch_config_get_database_upgrades (notmuch_config_t *config); + +void +notmuch_config_set_database_upgrades (notmuch_config_t *config, + const char *database_upgrades); + +const char * notmuch_config_get_user_name (notmuch_config_t *config); void diff --git a/notmuch-config.c b/notmuch-config.c index 8d28653..8f4ce99 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -32,11 +32,16 @@ static const char toplevel_config_comment[] = static const char database_config_comment[] = " Database configuration\n" "\n" - " The only value supported here is 'path' which should be the top-level\n" - " directory where your mail currently exists and to where mail will be\n" - " delivered in the future. Files should be individual email messages.\n" - " Notmuch will store its database within a sub-directory of the path\n" - " configured here named \".notmuch\".\n"; + "The following options are supported here:\n" + "\n" + "\tpath The top-level directory where your mail currently exists\n" + "\t and to where mail will be delivered in the future. Files\n" + "\t should be individual email messages. Notmuch will store\n" + "\t its database within a sub-directory (named .notmuch) of\n" + "\t the path configured here.\n" + "\n" + "\tupgrades Set to 'yes' to enable automatic database upgrades.\n" + "\n"; static const char new_config_comment[] = " Configuration for \"notmuch new\"\n" @@ -107,6 +112,7 @@ struct _notmuch_config { notmuch_bool_t is_new; char *database_path; + char *database_upgrades; char *user_name; char *user_primary_email; const char **user_other_email; @@ -265,6 +271,7 @@ notmuch_config_open (void *ctx, config->is_new = FALSE; config->database_path = NULL; + config->database_upgrades = NULL; config->user_name = NULL; config->user_primary_email = NULL; config->user_other_email = NULL; @@ -328,6 +335,10 @@ notmuch_config_open (void *ctx, talloc_free (path); } + if (notmuch_config_get_database_upgrades (config) == NULL) { + notmuch_config_set_database_upgrades (config, "no"); + } + if (notmuch_config_get_user_name (config) == NULL) { char *name = get_name_from_passwd_file (config); notmuch_config_set_user_name (config, name); @@ -582,6 +593,19 @@ notmuch_config_set_database_path (notmuch_config_t *config, } const char * +notmuch_config_get_database_upgrades (notmuch_config_t *config) +{ + return _config_get (config, &config->database_upgrades, "database", "upgrades"); +} + +void +notmuch_config_set_database_upgrades (notmuch_config_t *config, + const char *database_upgrades) +{ + _config_set (config, &config->database_upgrades, "database", "upgrades", database_upgrades); +} + +const char * notmuch_config_get_user_name (notmuch_config_t *config) { return _config_get (config, &config->user_name, "user", "name"); diff --git a/test/T030-config.sh b/test/T030-config.sh index ca4cf33..d095f0e 100755 --- a/test/T030-config.sh +++ b/test/T030-config.sh @@ -47,6 +47,7 @@ notmuch config set database.path "/canonical/path" output=$(notmuch config list) test_expect_equal "$output" "\ database.path=/canonical/path +database.upgrades=no user.name=Notmuch Test Suite user.primary_email=test_suite@notmuchmail.org user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org diff --git a/test/T040-setup.sh b/test/T040-setup.sh index 124ef1c..46fd327 100755 --- a/test/T040-setup.sh +++ b/test/T040-setup.sh @@ -16,6 +16,7 @@ EOF output=$(notmuch --config=new-notmuch-config config list) test_expect_equal "$output" "\ database.path=/path/to/maildir +database.upgrades=no user.name=Test Suite user.primary_email=test.suite@example.com user.other_email=another.suite@example.com; -- 1.9.0