--- /dev/null
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id C08C7431FC0\r
+ for <notmuch@notmuchmail.org>; Tue, 29 Jan 2013 13:46:48 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id Wr3dDcjZ83O9 for <notmuch@notmuchmail.org>;\r
+ Tue, 29 Jan 2013 13:46:46 -0800 (PST)\r
+Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com\r
+ [209.85.217.180]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 33259431FC7\r
+ for <notmuch@notmuchmail.org>; Tue, 29 Jan 2013 13:46:44 -0800 (PST)\r
+Received: by mail-lb0-f180.google.com with SMTP id q12so1346139lbc.11\r
+ for <notmuch@notmuchmail.org>; Tue, 29 Jan 2013 13:46:42 -0800 (PST)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=google.com; s=20120113;\r
+ h=x-received:from:to:subject:date:message-id:x-mailer:in-reply-to\r
+ :references:in-reply-to:references:x-gm-message-state;\r
+ bh=AprAEVOn2F1FQ/1jgdf9PZml3difnM49BD/sSq5KuVA=;\r
+ b=NNqQg6f0eEgKsL3LPFO5l0WRWjKurBE78GTXlCwHbNMCJF99BKyhYTwd2XJQluJmJn\r
+ bcO+TDKmH4waVu99Usri6Ddi9PmsRuCNERdrnZg/xEYqe2HYnReWRBD/gldB26suovRj\r
+ MbKuZplAmt1l9ttsMx93CKcn72ysA6CgKwDrHOmPzKqU2UyjHaKm6FQFZyP6zqH7CMEO\r
+ zRhldi6lhOsppPJhaIlMYOH9d0sJAI4VLlwYktpiSWrgPKy7io6AXBRmQUO0uSI27eJO\r
+ ZkduiYCEKIXQxNuPmiYZOBZ8hiC0FnOPSN7qVDH4VrGVeJ4AcavPT9ffPiLtdK5jqZg0\r
+ Z2bA==\r
+X-Received: by 10.112.44.229 with SMTP id h5mr1097991lbm.12.1359496002607;\r
+ Tue, 29 Jan 2013 13:46:42 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi.\r
+ [80.223.81.27])\r
+ by mx.google.com with ESMTPS id z4sm5588640lbn.17.2013.01.29.13.46.39\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Tue, 29 Jan 2013 13:46:41 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/6] cli: make notmuch_config_open() "is new" parameter input\r
+ only\r
+Date: Tue, 29 Jan 2013 23:46:20 +0200\r
+Message-Id:\r
+ <697799bff100a6ab0467016dc717c7f210eeeb4a.1359495450.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <cover.1359495450.git.jani@nikula.org>\r
+References: <cover.1359495450.git.jani@nikula.org>\r
+In-Reply-To: <cover.1359495450.git.jani@nikula.org>\r
+References: <cover.1359495450.git.jani@nikula.org>\r
+X-Gm-Message-State:\r
+ ALoCoQn/qvOY1g7zSEhd66PkDfZTNCQjyDXnYPpxQclGFMbIyaBFOaJAYjoxTe8/RBZazhD9ndBF\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 29 Jan 2013 21:46:48 -0000\r
+\r
+Use the notmuch_config_is_new() function instead.\r
+---\r
+ notmuch-client.h | 2 +-\r
+ notmuch-config.c | 32 +++++++++++---------------------\r
+ notmuch-count.c | 2 +-\r
+ notmuch-dump.c | 2 +-\r
+ notmuch-new.c | 2 +-\r
+ notmuch-reply.c | 2 +-\r
+ notmuch-restore.c | 2 +-\r
+ notmuch-search.c | 2 +-\r
+ notmuch-setup.c | 7 +++----\r
+ notmuch-show.c | 2 +-\r
+ notmuch-tag.c | 2 +-\r
+ notmuch.c | 5 ++---\r
+ test/random-corpus.c | 2 +-\r
+ 13 files changed, 26 insertions(+), 38 deletions(-)\r
+\r
+diff --git a/notmuch-client.h b/notmuch-client.h\r
+index 07367e0..b3dcb21 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -248,7 +248,7 @@ typedef struct _notmuch_config notmuch_config_t;\r
+ notmuch_config_t *\r
+ notmuch_config_open (void *ctx,\r
+ const char *filename,\r
+- notmuch_bool_t *is_new_ret);\r
++ notmuch_bool_t create_new);\r
+ \r
+ void\r
+ notmuch_config_close (notmuch_config_t *config);\r
+diff --git a/notmuch-config.c b/notmuch-config.c\r
+index e733e92..247fbe4 100644\r
+--- a/notmuch-config.c\r
++++ b/notmuch-config.c\r
+@@ -233,10 +233,9 @@ get_username_from_passwd_file (void *ctx)\r
+ notmuch_config_t *\r
+ notmuch_config_open (void *ctx,\r
+ const char *filename,\r
+- notmuch_bool_t *is_new_ret)\r
++ notmuch_bool_t create_new)\r
+ {\r
+ GError *error = NULL;\r
+- int is_new = 0;\r
+ size_t tmp;\r
+ char *notmuch_config_env = NULL;\r
+ int file_had_database_group;\r
+@@ -245,9 +244,6 @@ notmuch_config_open (void *ctx,\r
+ int file_had_maildir_group;\r
+ int file_had_search_group;\r
+ \r
+- if (is_new_ret)\r
+- *is_new_ret = 0;\r
+-\r
+ notmuch_config_t *config = talloc (ctx, notmuch_config_t);\r
+ if (config == NULL) {\r
+ fprintf (stderr, "Out of memory.\n");\r
+@@ -286,17 +282,16 @@ notmuch_config_open (void *ctx,\r
+ G_KEY_FILE_KEEP_COMMENTS,\r
+ &error))\r
+ {\r
+- /* If the caller passed a non-NULL value for is_new_ret, then\r
+- * the caller is prepared for a default configuration file in\r
+- * the case of FILE NOT FOUND. Otherwise, any read failure is\r
+- * an error.\r
++ /* If create_new is true, then the caller is prepared for a\r
++ * default configuration file in the case of FILE NOT\r
++ * FOUND. Otherwise, any read failure is an error.\r
+ */\r
+- if (is_new_ret &&\r
++ if (create_new &&\r
+ error->domain == G_FILE_ERROR &&\r
+ error->code == G_FILE_ERROR_NOENT)\r
+ {\r
+ g_error_free (error);\r
+- is_new = 1;\r
++ config->is_new = TRUE;\r
+ }\r
+ else\r
+ {\r
+@@ -379,7 +374,7 @@ notmuch_config_open (void *ctx,\r
+ }\r
+ \r
+ if (notmuch_config_get_search_exclude_tags (config, &tmp) == NULL) {\r
+- if (is_new) {\r
++ if (config->is_new) {\r
+ const char *tags[] = { "deleted", "spam" };\r
+ notmuch_config_set_search_exclude_tags (config, tags, 2);\r
+ } else {\r
+@@ -399,7 +394,7 @@ notmuch_config_open (void *ctx,\r
+ /* Whenever we know of configuration sections that don't appear in\r
+ * the configuration file, we add some comments to help the user\r
+ * understand what can be done. */\r
+- if (is_new)\r
++ if (config->is_new)\r
+ {\r
+ g_key_file_set_comment (config->key_file, NULL, NULL,\r
+ toplevel_config_comment, NULL);\r
+@@ -434,11 +429,6 @@ notmuch_config_open (void *ctx,\r
+ search_config_comment, NULL);\r
+ }\r
+ \r
+- if (is_new_ret)\r
+- *is_new_ret = is_new;\r
+-\r
+- config->is_new = is_new;\r
+-\r
+ return config;\r
+ }\r
+ \r
+@@ -719,7 +709,7 @@ notmuch_config_command_get (void *ctx, char *item)\r
+ {\r
+ notmuch_config_t *config;\r
+ \r
+- config = notmuch_config_open (ctx, NULL, NULL);\r
++ config = notmuch_config_open (ctx, NULL, FALSE);\r
+ if (config == NULL)\r
+ return 1;\r
+ \r
+@@ -781,7 +771,7 @@ notmuch_config_command_set (void *ctx, char *item, int argc, char *argv[])\r
+ if (_item_split (item, &group, &key))\r
+ return 1;\r
+ \r
+- config = notmuch_config_open (ctx, NULL, NULL);\r
++ config = notmuch_config_open (ctx, NULL, FALSE);\r
+ if (config == NULL)\r
+ return 1;\r
+ \r
+@@ -818,7 +808,7 @@ notmuch_config_command_list (void *ctx)\r
+ char **groups;\r
+ size_t g, groups_length;\r
+ \r
+- config = notmuch_config_open (ctx, NULL, NULL);\r
++ config = notmuch_config_open (ctx, NULL, FALSE);\r
+ if (config == NULL)\r
+ return 1;\r
+ \r
+diff --git a/notmuch-count.c b/notmuch-count.c\r
+index 2f98128..61722ed 100644\r
+--- a/notmuch-count.c\r
++++ b/notmuch-count.c\r
+@@ -62,7 +62,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
+ return 1;\r
+ }\r
+ \r
+- config = notmuch_config_open (ctx, NULL, NULL);\r
++ config = notmuch_config_open (ctx, NULL, FALSE);\r
+ if (config == NULL)\r
+ return 1;\r
+ \r
+diff --git a/notmuch-dump.c b/notmuch-dump.c\r
+index a3244e0..845a67e 100644\r
+--- a/notmuch-dump.c\r
++++ b/notmuch-dump.c\r
+@@ -34,7 +34,7 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])\r
+ notmuch_tags_t *tags;\r
+ const char *query_str = "";\r
+ \r
+- config = notmuch_config_open (ctx, NULL, NULL);\r
++ config = notmuch_config_open (ctx, NULL, FALSE);\r
+ if (config == NULL)\r
+ return 1;\r
+ \r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index feb9c32..4915418 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -875,7 +875,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
+ return 1;\r
+ }\r
+ \r
+- config = notmuch_config_open (ctx, NULL, NULL);\r
++ config = notmuch_config_open (ctx, NULL, FALSE);\r
+ if (config == NULL)\r
+ return 1;\r
+ \r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index 22c58ff..9da42b9 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -762,7 +762,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+ \r
+ notmuch_exit_if_unsupported_format ();\r
+ \r
+- config = notmuch_config_open (ctx, NULL, NULL);\r
++ config = notmuch_config_open (ctx, NULL, FALSE);\r
+ if (config == NULL)\r
+ return 1;\r
+ \r
+diff --git a/notmuch-restore.c b/notmuch-restore.c\r
+index cf26a42..dd2507f 100644\r
+--- a/notmuch-restore.c\r
++++ b/notmuch-restore.c\r
+@@ -139,7 +139,7 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])\r
+ int opt_index;\r
+ int input_format = DUMP_FORMAT_AUTO;\r
+ \r
+- config = notmuch_config_open (ctx, NULL, NULL);\r
++ config = notmuch_config_open (ctx, NULL, FALSE);\r
+ if (config == NULL)\r
+ return 1;\r
+ \r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 0b0a879..fac6663 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -371,7 +371,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
+ \r
+ notmuch_exit_if_unsupported_format ();\r
+ \r
+- config = notmuch_config_open (ctx, NULL, NULL);\r
++ config = notmuch_config_open (ctx, NULL, FALSE);\r
+ if (config == NULL)\r
+ return 1;\r
+ \r
+diff --git a/notmuch-setup.c b/notmuch-setup.c\r
+index 94d0aa7..72d862a 100644\r
+--- a/notmuch-setup.c\r
++++ b/notmuch-setup.c\r
+@@ -130,7 +130,6 @@ notmuch_setup_command (unused (void *ctx),\r
+ size_t old_other_emails_len;\r
+ GPtrArray *other_emails;\r
+ unsigned int i;\r
+- int is_new;\r
+ const char **new_tags;\r
+ size_t new_tags_len;\r
+ const char **search_exclude_tags;\r
+@@ -147,9 +146,9 @@ notmuch_setup_command (unused (void *ctx),\r
+ chomp_newline (response); \\r
+ } while (0)\r
+ \r
+- config = notmuch_config_open (ctx, NULL, &is_new);\r
++ config = notmuch_config_open (ctx, NULL, TRUE);\r
+ \r
+- if (is_new)\r
++ if (notmuch_config_is_new (config))\r
+ welcome_message_pre_setup ();\r
+ \r
+ prompt ("Your full name [%s]: ", notmuch_config_get_user_name (config));\r
+@@ -229,7 +228,7 @@ notmuch_setup_command (unused (void *ctx),\r
+ \r
+ \r
+ if (! notmuch_config_save (config)) {\r
+- if (is_new)\r
++ if (notmuch_config_is_new (config))\r
+ welcome_message_post_setup ();\r
+ return 0;\r
+ } else {\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index cbfc2d1..5ae5d7d 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -1176,7 +1176,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+ else\r
+ params.entire_thread = FALSE;\r
+ \r
+- config = notmuch_config_open (ctx, NULL, NULL);\r
++ config = notmuch_config_open (ctx, NULL, FALSE);\r
+ if (config == NULL)\r
+ return 1;\r
+ \r
+diff --git a/notmuch-tag.c b/notmuch-tag.c\r
+index d9daf8f..148e856 100644\r
+--- a/notmuch-tag.c\r
++++ b/notmuch-tag.c\r
+@@ -236,7 +236,7 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])\r
+ return 1;\r
+ }\r
+ \r
+- config = notmuch_config_open (ctx, NULL, NULL);\r
++ config = notmuch_config_open (ctx, NULL, FALSE);\r
+ if (config == NULL)\r
+ return 1;\r
+ \r
+diff --git a/notmuch.c b/notmuch.c\r
+index a674481..b413b53 100644\r
+--- a/notmuch.c\r
++++ b/notmuch.c\r
+@@ -187,16 +187,15 @@ static int\r
+ notmuch (void *ctx)\r
+ {\r
+ notmuch_config_t *config;\r
+- notmuch_bool_t is_new;\r
+ char *db_path;\r
+ struct stat st;\r
+ \r
+- config = notmuch_config_open (ctx, NULL, &is_new);\r
++ config = notmuch_config_open (ctx, NULL, TRUE);\r
+ \r
+ /* If the user has never configured notmuch, then run\r
+ * notmuch_setup_command which will give a nice welcome message,\r
+ * and interactively guide the user through the configuration. */\r
+- if (is_new) {\r
++ if (notmuch_config_is_new (config)) {\r
+ notmuch_config_close (config);\r
+ return notmuch_setup_command (ctx, 0, NULL);\r
+ }\r
+diff --git a/test/random-corpus.c b/test/random-corpus.c\r
+index 8b7748e..790193d 100644\r
+--- a/test/random-corpus.c\r
++++ b/test/random-corpus.c\r
+@@ -160,7 +160,7 @@ main (int argc, char **argv)\r
+ exit (1);\r
+ }\r
+ \r
+- config = notmuch_config_open (ctx, config_path, NULL);\r
++ config = notmuch_config_open (ctx, config_path, FALSE);\r
+ if (config == NULL)\r
+ return 1;\r
+ \r
+-- \r
+1.7.10.4\r
+\r