aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--notmuch-config.c26
-rwxr-xr-xtest/T040-setup.sh6
2 files changed, 22 insertions, 10 deletions
diff --git a/notmuch-config.c b/notmuch-config.c
index db487dbe..a564bcae 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -283,16 +283,22 @@ notmuch_config_open (void *ctx,
G_KEY_FILE_KEEP_COMMENTS,
&error))
{
- /* If create_new is true, then the caller is prepared for a
- * default configuration file in the case of FILE NOT
- * FOUND. Otherwise, any read failure is an error.
- */
- if (create_new &&
- error->domain == G_FILE_ERROR &&
- error->code == G_FILE_ERROR_NOENT)
- {
- g_error_free (error);
- config->is_new = TRUE;
+ if (error->domain == G_FILE_ERROR && error->code == G_FILE_ERROR_NOENT) {
+ /* If create_new is true, then the caller is prepared for a
+ * default configuration file in the case of FILE NOT
+ * FOUND.
+ */
+ if (create_new) {
+ g_error_free (error);
+ config->is_new = TRUE;
+ } else {
+ fprintf (stderr, "Configuration file %s not found.\n"
+ "Try running 'notmuch setup' to create a configuration.\n",
+ config->filename);
+ talloc_free (config);
+ g_error_free (error);
+ return NULL;
+ }
}
else
{
diff --git a/test/T040-setup.sh b/test/T040-setup.sh
index 124ef1c8..b1972e70 100755
--- a/test/T040-setup.sh
+++ b/test/T040-setup.sh
@@ -3,6 +3,12 @@
test_description='"notmuch setup"'
. ./test-lib.sh
+test_begin_subtest "Notmuch new without a config suggests notmuch setup"
+output=$(notmuch --config=new-notmuch-config new 2>&1)
+test_expect_equal "$output" "\
+Configuration file new-notmuch-config not found.
+Try running 'notmuch setup' to create a configuration."
+
test_begin_subtest "Create a new config interactively"
notmuch --config=new-notmuch-config > /dev/null <<EOF
Test Suite