--- /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 6C41F429E25\r
+ for <notmuch@notmuchmail.org>; Sun, 3 Mar 2013 13:55:37 -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 E50fYIkb1IFp for <notmuch@notmuchmail.org>;\r
+ Sun, 3 Mar 2013 13:55:34 -0800 (PST)\r
+Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com\r
+ [209.85.217.179]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 942C8431FAE\r
+ for <notmuch@notmuchmail.org>; Sun, 3 Mar 2013 13:55:25 -0800 (PST)\r
+Received: by mail-lb0-f179.google.com with SMTP id j14so3506579lbo.10\r
+ for <notmuch@notmuchmail.org>; Sun, 03 Mar 2013 13:55:24 -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:cc:subject:date:message-id:x-mailer:in-reply-to\r
+ :references:in-reply-to:references:x-gm-message-state;\r
+ bh=6yGGNMOFH3Wsp9Py5WltSKwvD9/MYnI7KjrSJpNuoO8=;\r
+ b=T4GrSps9+5jNwmTU5MC59TRKbrpH2HQk5R8Jicoy3/MFgTZqsesP/GT8VKJlhSVOIh\r
+ 8DaWgbxH/oPr5KJqMFkvERGXwgmh460JzLFdD8oRYWVJ6Xf4Ev7yVH8zC7U2HS3Uq7hR\r
+ nvry3cXWKpEM7KoybtSaBxAdD0A6VxTv/jpaqPFFoXK/Lyt6WsOUX80dKc/q4ZcUosru\r
+ 3KUdTs36vl14Wk0poP/GmB2cYqiGQCrRfSUdD6MaGP5ZGQZ/7XtNYFmo0kUrttn3vflO\r
+ bL9/KdDmd5TUs/LvFyNoZNsP2fv4+f72yJ09xGMV9KRQLWauyOrgdWPp+G+c2P15VLNx\r
+ ynCA==\r
+X-Received: by 10.112.23.136 with SMTP id m8mr3665256lbf.53.1362347724020;\r
+ Sun, 03 Mar 2013 13:55:24 -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 ev7sm6608297lbb.15.2013.03.03.13.55.22\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sun, 03 Mar 2013 13:55:23 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 4/6] cli: config: make notmuch_config_open() "is new"\r
+ parameter input only\r
+Date: Sun, 3 Mar 2013 23:55:08 +0200\r
+Message-Id:\r
+ <5faebfc5d36d7e85a4dd1acbca0417d8a6a2602d.1362347362.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <cover.1362347362.git.jani@nikula.org>\r
+References: <cover.1362347362.git.jani@nikula.org>\r
+In-Reply-To: <cover.1362347362.git.jani@nikula.org>\r
+References: <cover.1362347362.git.jani@nikula.org>\r
+X-Gm-Message-State:\r
+ ALoCoQlar5YEbUpyT5C+8HigLFhRYDpD5/dponXclI3wg6H1pc09IP5yO4ATzXFtPmQfViXlnz22\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: Sun, 03 Mar 2013 21:55:38 -0000\r
+\r
+We now have a notmuch_config_is_new() function to query whether a\r
+config was created or not. Change the notmuch_config_open() is_new\r
+parameter into boolean create_new to determine whether the function\r
+should create a new config if one doesn't exist. This reduces the\r
+complexity of the API.\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 ec2f20f..e434d03 100644\r
+--- a/notmuch.c\r
++++ b/notmuch.c\r
+@@ -202,16 +202,15 @@ static int\r
+ notmuch_command (void *ctx, unused(int argc), unused(char *argv[]))\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