1 Return-Path: <jani@nikula.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id C08C7431FC0
\r
6 for <notmuch@notmuchmail.org>; Tue, 29 Jan 2013 13:46:48 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
\r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
13 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id Wr3dDcjZ83O9 for <notmuch@notmuchmail.org>;
\r
17 Tue, 29 Jan 2013 13:46:46 -0800 (PST)
\r
18 Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com
\r
19 [209.85.217.180]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 33259431FC7
\r
22 for <notmuch@notmuchmail.org>; Tue, 29 Jan 2013 13:46:44 -0800 (PST)
\r
23 Received: by mail-lb0-f180.google.com with SMTP id q12so1346139lbc.11
\r
24 for <notmuch@notmuchmail.org>; Tue, 29 Jan 2013 13:46:42 -0800 (PST)
\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
26 d=google.com; s=20120113;
\r
27 h=x-received:from:to:subject:date:message-id:x-mailer:in-reply-to
\r
28 :references:in-reply-to:references:x-gm-message-state;
\r
29 bh=AprAEVOn2F1FQ/1jgdf9PZml3difnM49BD/sSq5KuVA=;
\r
30 b=NNqQg6f0eEgKsL3LPFO5l0WRWjKurBE78GTXlCwHbNMCJF99BKyhYTwd2XJQluJmJn
\r
31 bcO+TDKmH4waVu99Usri6Ddi9PmsRuCNERdrnZg/xEYqe2HYnReWRBD/gldB26suovRj
\r
32 MbKuZplAmt1l9ttsMx93CKcn72ysA6CgKwDrHOmPzKqU2UyjHaKm6FQFZyP6zqH7CMEO
\r
33 zRhldi6lhOsppPJhaIlMYOH9d0sJAI4VLlwYktpiSWrgPKy7io6AXBRmQUO0uSI27eJO
\r
34 ZkduiYCEKIXQxNuPmiYZOBZ8hiC0FnOPSN7qVDH4VrGVeJ4AcavPT9ffPiLtdK5jqZg0
\r
36 X-Received: by 10.112.44.229 with SMTP id h5mr1097991lbm.12.1359496002607;
\r
37 Tue, 29 Jan 2013 13:46:42 -0800 (PST)
\r
38 Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi.
\r
40 by mx.google.com with ESMTPS id z4sm5588640lbn.17.2013.01.29.13.46.39
\r
41 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
42 Tue, 29 Jan 2013 13:46:41 -0800 (PST)
\r
43 From: Jani Nikula <jani@nikula.org>
\r
44 To: notmuch@notmuchmail.org
\r
45 Subject: [PATCH 2/6] cli: make notmuch_config_open() "is new" parameter input
\r
47 Date: Tue, 29 Jan 2013 23:46:20 +0200
\r
49 <697799bff100a6ab0467016dc717c7f210eeeb4a.1359495450.git.jani@nikula.org>
\r
50 X-Mailer: git-send-email 1.7.10.4
\r
51 In-Reply-To: <cover.1359495450.git.jani@nikula.org>
\r
52 References: <cover.1359495450.git.jani@nikula.org>
\r
53 In-Reply-To: <cover.1359495450.git.jani@nikula.org>
\r
54 References: <cover.1359495450.git.jani@nikula.org>
\r
56 ALoCoQn/qvOY1g7zSEhd66PkDfZTNCQjyDXnYPpxQclGFMbIyaBFOaJAYjoxTe8/RBZazhD9ndBF
\r
57 X-BeenThere: notmuch@notmuchmail.org
\r
58 X-Mailman-Version: 2.1.13
\r
60 List-Id: "Use and development of the notmuch mail system."
\r
61 <notmuch.notmuchmail.org>
\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
65 List-Post: <mailto:notmuch@notmuchmail.org>
\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
69 X-List-Received-Date: Tue, 29 Jan 2013 21:46:48 -0000
\r
71 Use the notmuch_config_is_new() function instead.
\r
73 notmuch-client.h | 2 +-
\r
74 notmuch-config.c | 32 +++++++++++---------------------
\r
75 notmuch-count.c | 2 +-
\r
76 notmuch-dump.c | 2 +-
\r
77 notmuch-new.c | 2 +-
\r
78 notmuch-reply.c | 2 +-
\r
79 notmuch-restore.c | 2 +-
\r
80 notmuch-search.c | 2 +-
\r
81 notmuch-setup.c | 7 +++----
\r
82 notmuch-show.c | 2 +-
\r
83 notmuch-tag.c | 2 +-
\r
85 test/random-corpus.c | 2 +-
\r
86 13 files changed, 26 insertions(+), 38 deletions(-)
\r
88 diff --git a/notmuch-client.h b/notmuch-client.h
\r
89 index 07367e0..b3dcb21 100644
\r
90 --- a/notmuch-client.h
\r
91 +++ b/notmuch-client.h
\r
92 @@ -248,7 +248,7 @@ typedef struct _notmuch_config notmuch_config_t;
\r
94 notmuch_config_open (void *ctx,
\r
95 const char *filename,
\r
96 - notmuch_bool_t *is_new_ret);
\r
97 + notmuch_bool_t create_new);
\r
100 notmuch_config_close (notmuch_config_t *config);
\r
101 diff --git a/notmuch-config.c b/notmuch-config.c
\r
102 index e733e92..247fbe4 100644
\r
103 --- a/notmuch-config.c
\r
104 +++ b/notmuch-config.c
\r
105 @@ -233,10 +233,9 @@ get_username_from_passwd_file (void *ctx)
\r
107 notmuch_config_open (void *ctx,
\r
108 const char *filename,
\r
109 - notmuch_bool_t *is_new_ret)
\r
110 + notmuch_bool_t create_new)
\r
112 GError *error = NULL;
\r
115 char *notmuch_config_env = NULL;
\r
116 int file_had_database_group;
\r
117 @@ -245,9 +244,6 @@ notmuch_config_open (void *ctx,
\r
118 int file_had_maildir_group;
\r
119 int file_had_search_group;
\r
124 notmuch_config_t *config = talloc (ctx, notmuch_config_t);
\r
125 if (config == NULL) {
\r
126 fprintf (stderr, "Out of memory.\n");
\r
127 @@ -286,17 +282,16 @@ notmuch_config_open (void *ctx,
\r
128 G_KEY_FILE_KEEP_COMMENTS,
\r
131 - /* If the caller passed a non-NULL value for is_new_ret, then
\r
132 - * the caller is prepared for a default configuration file in
\r
133 - * the case of FILE NOT FOUND. Otherwise, any read failure is
\r
135 + /* If create_new is true, then the caller is prepared for a
\r
136 + * default configuration file in the case of FILE NOT
\r
137 + * FOUND. Otherwise, any read failure is an error.
\r
139 - if (is_new_ret &&
\r
140 + if (create_new &&
\r
141 error->domain == G_FILE_ERROR &&
\r
142 error->code == G_FILE_ERROR_NOENT)
\r
144 g_error_free (error);
\r
146 + config->is_new = TRUE;
\r
150 @@ -379,7 +374,7 @@ notmuch_config_open (void *ctx,
\r
153 if (notmuch_config_get_search_exclude_tags (config, &tmp) == NULL) {
\r
155 + if (config->is_new) {
\r
156 const char *tags[] = { "deleted", "spam" };
\r
157 notmuch_config_set_search_exclude_tags (config, tags, 2);
\r
159 @@ -399,7 +394,7 @@ notmuch_config_open (void *ctx,
\r
160 /* Whenever we know of configuration sections that don't appear in
\r
161 * the configuration file, we add some comments to help the user
\r
162 * understand what can be done. */
\r
164 + if (config->is_new)
\r
166 g_key_file_set_comment (config->key_file, NULL, NULL,
\r
167 toplevel_config_comment, NULL);
\r
168 @@ -434,11 +429,6 @@ notmuch_config_open (void *ctx,
\r
169 search_config_comment, NULL);
\r
173 - *is_new_ret = is_new;
\r
175 - config->is_new = is_new;
\r
180 @@ -719,7 +709,7 @@ notmuch_config_command_get (void *ctx, char *item)
\r
182 notmuch_config_t *config;
\r
184 - config = notmuch_config_open (ctx, NULL, NULL);
\r
185 + config = notmuch_config_open (ctx, NULL, FALSE);
\r
186 if (config == NULL)
\r
189 @@ -781,7 +771,7 @@ notmuch_config_command_set (void *ctx, char *item, int argc, char *argv[])
\r
190 if (_item_split (item, &group, &key))
\r
193 - config = notmuch_config_open (ctx, NULL, NULL);
\r
194 + config = notmuch_config_open (ctx, NULL, FALSE);
\r
195 if (config == NULL)
\r
198 @@ -818,7 +808,7 @@ notmuch_config_command_list (void *ctx)
\r
200 size_t g, groups_length;
\r
202 - config = notmuch_config_open (ctx, NULL, NULL);
\r
203 + config = notmuch_config_open (ctx, NULL, FALSE);
\r
204 if (config == NULL)
\r
207 diff --git a/notmuch-count.c b/notmuch-count.c
\r
208 index 2f98128..61722ed 100644
\r
209 --- a/notmuch-count.c
\r
210 +++ b/notmuch-count.c
\r
211 @@ -62,7 +62,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
\r
215 - config = notmuch_config_open (ctx, NULL, NULL);
\r
216 + config = notmuch_config_open (ctx, NULL, FALSE);
\r
217 if (config == NULL)
\r
220 diff --git a/notmuch-dump.c b/notmuch-dump.c
\r
221 index a3244e0..845a67e 100644
\r
222 --- a/notmuch-dump.c
\r
223 +++ b/notmuch-dump.c
\r
224 @@ -34,7 +34,7 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
\r
225 notmuch_tags_t *tags;
\r
226 const char *query_str = "";
\r
228 - config = notmuch_config_open (ctx, NULL, NULL);
\r
229 + config = notmuch_config_open (ctx, NULL, FALSE);
\r
230 if (config == NULL)
\r
233 diff --git a/notmuch-new.c b/notmuch-new.c
\r
234 index feb9c32..4915418 100644
\r
235 --- a/notmuch-new.c
\r
236 +++ b/notmuch-new.c
\r
237 @@ -875,7 +875,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
241 - config = notmuch_config_open (ctx, NULL, NULL);
\r
242 + config = notmuch_config_open (ctx, NULL, FALSE);
\r
243 if (config == NULL)
\r
246 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
247 index 22c58ff..9da42b9 100644
\r
248 --- a/notmuch-reply.c
\r
249 +++ b/notmuch-reply.c
\r
250 @@ -762,7 +762,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
252 notmuch_exit_if_unsupported_format ();
\r
254 - config = notmuch_config_open (ctx, NULL, NULL);
\r
255 + config = notmuch_config_open (ctx, NULL, FALSE);
\r
256 if (config == NULL)
\r
259 diff --git a/notmuch-restore.c b/notmuch-restore.c
\r
260 index cf26a42..dd2507f 100644
\r
261 --- a/notmuch-restore.c
\r
262 +++ b/notmuch-restore.c
\r
263 @@ -139,7 +139,7 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
\r
265 int input_format = DUMP_FORMAT_AUTO;
\r
267 - config = notmuch_config_open (ctx, NULL, NULL);
\r
268 + config = notmuch_config_open (ctx, NULL, FALSE);
\r
269 if (config == NULL)
\r
272 diff --git a/notmuch-search.c b/notmuch-search.c
\r
273 index 0b0a879..fac6663 100644
\r
274 --- a/notmuch-search.c
\r
275 +++ b/notmuch-search.c
\r
276 @@ -371,7 +371,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
278 notmuch_exit_if_unsupported_format ();
\r
280 - config = notmuch_config_open (ctx, NULL, NULL);
\r
281 + config = notmuch_config_open (ctx, NULL, FALSE);
\r
282 if (config == NULL)
\r
285 diff --git a/notmuch-setup.c b/notmuch-setup.c
\r
286 index 94d0aa7..72d862a 100644
\r
287 --- a/notmuch-setup.c
\r
288 +++ b/notmuch-setup.c
\r
289 @@ -130,7 +130,6 @@ notmuch_setup_command (unused (void *ctx),
\r
290 size_t old_other_emails_len;
\r
291 GPtrArray *other_emails;
\r
294 const char **new_tags;
\r
295 size_t new_tags_len;
\r
296 const char **search_exclude_tags;
\r
297 @@ -147,9 +146,9 @@ notmuch_setup_command (unused (void *ctx),
\r
298 chomp_newline (response); \
\r
301 - config = notmuch_config_open (ctx, NULL, &is_new);
\r
302 + config = notmuch_config_open (ctx, NULL, TRUE);
\r
305 + if (notmuch_config_is_new (config))
\r
306 welcome_message_pre_setup ();
\r
308 prompt ("Your full name [%s]: ", notmuch_config_get_user_name (config));
\r
309 @@ -229,7 +228,7 @@ notmuch_setup_command (unused (void *ctx),
\r
312 if (! notmuch_config_save (config)) {
\r
314 + if (notmuch_config_is_new (config))
\r
315 welcome_message_post_setup ();
\r
318 diff --git a/notmuch-show.c b/notmuch-show.c
\r
319 index cbfc2d1..5ae5d7d 100644
\r
320 --- a/notmuch-show.c
\r
321 +++ b/notmuch-show.c
\r
322 @@ -1176,7 +1176,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
324 params.entire_thread = FALSE;
\r
326 - config = notmuch_config_open (ctx, NULL, NULL);
\r
327 + config = notmuch_config_open (ctx, NULL, FALSE);
\r
328 if (config == NULL)
\r
331 diff --git a/notmuch-tag.c b/notmuch-tag.c
\r
332 index d9daf8f..148e856 100644
\r
333 --- a/notmuch-tag.c
\r
334 +++ b/notmuch-tag.c
\r
335 @@ -236,7 +236,7 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])
\r
339 - config = notmuch_config_open (ctx, NULL, NULL);
\r
340 + config = notmuch_config_open (ctx, NULL, FALSE);
\r
341 if (config == NULL)
\r
344 diff --git a/notmuch.c b/notmuch.c
\r
345 index a674481..b413b53 100644
\r
348 @@ -187,16 +187,15 @@ static int
\r
349 notmuch (void *ctx)
\r
351 notmuch_config_t *config;
\r
352 - notmuch_bool_t is_new;
\r
356 - config = notmuch_config_open (ctx, NULL, &is_new);
\r
357 + config = notmuch_config_open (ctx, NULL, TRUE);
\r
359 /* If the user has never configured notmuch, then run
\r
360 * notmuch_setup_command which will give a nice welcome message,
\r
361 * and interactively guide the user through the configuration. */
\r
363 + if (notmuch_config_is_new (config)) {
\r
364 notmuch_config_close (config);
\r
365 return notmuch_setup_command (ctx, 0, NULL);
\r
367 diff --git a/test/random-corpus.c b/test/random-corpus.c
\r
368 index 8b7748e..790193d 100644
\r
369 --- a/test/random-corpus.c
\r
370 +++ b/test/random-corpus.c
\r
371 @@ -160,7 +160,7 @@ main (int argc, char **argv)
\r
375 - config = notmuch_config_open (ctx, config_path, NULL);
\r
376 + config = notmuch_config_open (ctx, config_path, FALSE);
\r
377 if (config == NULL)
\r