[PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / a6 / b9b0665c031230ea0e1571e9776dde1e8628a1
1 Return-Path: <bremner@tesseract.cs.unb.ca>\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 arlo.cworth.org (Postfix) with ESMTP id A90A46DE1B72\r
6  for <notmuch@notmuchmail.org>; Sun,  5 Apr 2015 16:01:18 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.575\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.575 tagged_above=-999 required=5 tests=[AWL=0.565, \r
12  T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id mGpQNBG8B7aO for <notmuch@notmuchmail.org>;\r
16  Sun,  5 Apr 2015 16:01:17 -0700 (PDT)\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
18  [87.98.215.224])\r
19  by arlo.cworth.org (Postfix) with ESMTPS id D369E6DE1B6F\r
20  for <notmuch@notmuchmail.org>; Sun,  5 Apr 2015 16:01:16 -0700 (PDT)\r
21 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
22  4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
23  id 1YetWs-0002ob-TW; Sun, 05 Apr 2015 23:00:34 +0000\r
24 Received: (nullmailer pid 2259 invoked by uid 1000); Sun, 05 Apr 2015\r
25  22:59:25 -0000\r
26 From: David Bremner <david@tethera.net>\r
27 To: notmuch@notmuchmail.org\r
28 Subject: [WIP2 12/12] cli: add global option "--db-revision"\r
29 Date: Mon,  6 Apr 2015 07:59:14 +0900\r
30 Message-Id: <1428274754-1698-13-git-send-email-david@tethera.net>\r
31 X-Mailer: git-send-email 2.1.4\r
32 In-Reply-To: <1428274754-1698-1-git-send-email-david@tethera.net>\r
33 References: <1428274754-1698-1-git-send-email-david@tethera.net>\r
34 X-BeenThere: notmuch@notmuchmail.org\r
35 X-Mailman-Version: 2.1.18\r
36 Precedence: list\r
37 List-Id: "Use and development of the notmuch mail system."\r
38  <notmuch.notmuchmail.org>\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
40  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
42 List-Post: <mailto:notmuch@notmuchmail.org>\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
45  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
46 X-List-Received-Date: Sun, 05 Apr 2015 23:01:18 -0000\r
47 \r
48 The function notmuch_exit_if_unmatched_db_revision is split from\r
49 notmuch_process_shared_options because it needs an open notmuch\r
50 database.\r
51 ---\r
52  notmuch-client.h  |  5 +++++\r
53  notmuch-compact.c |  4 ++++\r
54  notmuch-config.c  |  4 ++++\r
55  notmuch-count.c   |  2 ++\r
56  notmuch-dump.c    |  2 ++\r
57  notmuch-insert.c  |  2 ++\r
58  notmuch-new.c     |  3 ++-\r
59  notmuch-reply.c   |  2 ++\r
60  notmuch-restore.c |  2 ++\r
61  notmuch-search.c  |  2 ++\r
62  notmuch-setup.c   |  4 ++++\r
63  notmuch-show.c    |  2 ++\r
64  notmuch-tag.c     |  2 ++\r
65  notmuch.c         | 18 ++++++++++++++++++\r
66  14 files changed, 53 insertions(+), 1 deletion(-)\r
67 \r
68 diff --git a/notmuch-client.h b/notmuch-client.h\r
69 index 76dbc38..24aa78a 100644\r
70 --- a/notmuch-client.h\r
71 +++ b/notmuch-client.h\r
72 @@ -466,6 +466,11 @@ notmuch_database_dump (notmuch_database_t *notmuch,\r
73                        notmuch_bool_t gzip_output);\r
74  \r
75  #include "command-line-arguments.h"\r
76 +\r
77 +extern char *notmuch_requested_db_revision;\r
78  extern const notmuch_opt_desc_t  notmuch_shared_options [];\r
79  void notmuch_process_shared_options (const char* help_name);\r
80 +\r
81 +void notmuch_exit_if_unmatched_db_revision (notmuch_database_t *notmuch);\r
82 +\r
83  #endif\r
84 diff --git a/notmuch-compact.c b/notmuch-compact.c\r
85 index 5be551d..3da4bfb 100644\r
86 --- a/notmuch-compact.c\r
87 +++ b/notmuch-compact.c\r
88 @@ -46,6 +46,10 @@ notmuch_compact_command (notmuch_config_t *config, int argc, char *argv[])\r
89      if (opt_index < 0)\r
90         return EXIT_FAILURE;\r
91  \r
92 +    if (notmuch_requested_db_revision)\r
93 +       fprintf (stderr, "Warning: ignoring --db-revision=%s\n",\r
94 +                notmuch_requested_db_revision);\r
95 +\r
96      notmuch_process_shared_options (argv[0]);\r
97  \r
98      if (! quiet)\r
99 diff --git a/notmuch-config.c b/notmuch-config.c\r
100 index 568b3dc..a9d4e73 100644\r
101 --- a/notmuch-config.c\r
102 +++ b/notmuch-config.c\r
103 @@ -883,6 +883,10 @@ notmuch_config_command (notmuch_config_t *config, int argc, char *argv[])\r
104      if (opt_index < 0)\r
105         return EXIT_FAILURE;\r
106  \r
107 +    if (notmuch_requested_db_revision)\r
108 +       fprintf (stderr, "Warning: ignoring --db-revision=%s\n",\r
109 +                notmuch_requested_db_revision);\r
110 +\r
111      notmuch_process_shared_options (argv[0]);\r
112  \r
113      /* skip subcommand argument */\r
114 diff --git a/notmuch-count.c b/notmuch-count.c\r
115 index 57a88a8..e29ac2b 100644\r
116 --- a/notmuch-count.c\r
117 +++ b/notmuch-count.c\r
118 @@ -175,6 +175,8 @@ notmuch_count_command (notmuch_config_t *config, int argc, char *argv[])\r
119                                NOTMUCH_DATABASE_MODE_READ_ONLY, &notmuch))\r
120         return EXIT_FAILURE;\r
121  \r
122 +    notmuch_exit_if_unmatched_db_revision (notmuch);\r
123 +\r
124      query_str = query_string_from_args (config, argc-opt_index, argv+opt_index);\r
125      if (query_str == NULL) {\r
126         fprintf (stderr, "Out of memory.\n");\r
127 diff --git a/notmuch-dump.c b/notmuch-dump.c\r
128 index fab22bd..9c0b82d 100644\r
129 --- a/notmuch-dump.c\r
130 +++ b/notmuch-dump.c\r
131 @@ -215,6 +215,8 @@ notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[])\r
132                                NOTMUCH_DATABASE_MODE_READ_WRITE, &notmuch))\r
133         return EXIT_FAILURE;\r
134  \r
135 +    notmuch_exit_if_unmatched_db_revision (notmuch);\r
136 +\r
137      char *output_file_name = NULL;\r
138      int opt_index;\r
139  \r
140 diff --git a/notmuch-insert.c b/notmuch-insert.c\r
141 index 697880f..63b7a48 100644\r
142 --- a/notmuch-insert.c\r
143 +++ b/notmuch-insert.c\r
144 @@ -536,6 +536,8 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])\r
145                                NOTMUCH_DATABASE_MODE_READ_WRITE, &notmuch))\r
146         return EXIT_FAILURE;\r
147  \r
148 +    notmuch_exit_if_unmatched_db_revision (notmuch);\r
149 +\r
150      /* Write the message to the Maildir new directory. */\r
151      newpath = maildir_write_new (config, STDIN_FILENO, maildir);\r
152      if (! newpath) {\r
153 diff --git a/notmuch-new.c b/notmuch-new.c\r
154 index 895f5d9..e494a3b 100644\r
155 --- a/notmuch-new.c\r
156 +++ b/notmuch-new.c\r
157 @@ -995,10 +995,11 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
158                 fputs (status_string, stderr);\r
159                 free (status_string);\r
160             }\r
161 -\r
162             return EXIT_FAILURE;\r
163         }\r
164  \r
165 +       notmuch_exit_if_unmatched_db_revision (notmuch);\r
166 +\r
167         if (notmuch_database_needs_upgrade (notmuch)) {\r
168             time_t now = time (NULL);\r
169             struct tm *gm_time = gmtime (&now);\r
170 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
171 index 4464741..52e0d9b 100644\r
172 --- a/notmuch-reply.c\r
173 +++ b/notmuch-reply.c\r
174 @@ -831,6 +831,8 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])\r
175                                NOTMUCH_DATABASE_MODE_READ_ONLY, &notmuch))\r
176         return EXIT_FAILURE;\r
177  \r
178 +    notmuch_exit_if_unmatched_db_revision (notmuch);\r
179 +\r
180      query = notmuch_query_create (notmuch, query_string);\r
181      if (query == NULL) {\r
182         fprintf (stderr, "Out of memory\n");\r
183 diff --git a/notmuch-restore.c b/notmuch-restore.c\r
184 index 2a534dc..3e96aa8 100644\r
185 --- a/notmuch-restore.c\r
186 +++ b/notmuch-restore.c\r
187 @@ -165,6 +165,8 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])\r
188      }\r
189  \r
190      notmuch_process_shared_options (argv[0]);\r
191 +    notmuch_exit_if_unmatched_db_revision (notmuch);\r
192 +\r
193      name_for_error = input_file_name ? input_file_name : "stdin";\r
194  \r
195      if (! accumulate)\r
196 diff --git a/notmuch-search.c b/notmuch-search.c\r
197 index 5d17dac..453a041 100644\r
198 --- a/notmuch-search.c\r
199 +++ b/notmuch-search.c\r
200 @@ -583,6 +583,8 @@ _notmuch_search_prepare (search_context_t *ctx, notmuch_config_t *config, int ar\r
201         return EXIT_FAILURE;\r
202      }\r
203  \r
204 +    notmuch_exit_if_unmatched_db_revision (ctx->notmuch);\r
205 +\r
206      query_str = query_string_from_args (ctx->notmuch, argc, argv);\r
207      if (query_str == NULL) {\r
208         fprintf (stderr, "Out of memory.\n");\r
209 diff --git a/notmuch-setup.c b/notmuch-setup.c\r
210 index 5fc6e25..ddc6491 100644\r
211 --- a/notmuch-setup.c\r
212 +++ b/notmuch-setup.c\r
213 @@ -155,6 +155,10 @@ notmuch_setup_command (notmuch_config_t *config,\r
214      if (opt_index < 0)\r
215         return EXIT_FAILURE;\r
216  \r
217 +    if (notmuch_requested_db_revision)\r
218 +       fprintf (stderr, "Warning: ignoring --db-revision=%s\n",\r
219 +                notmuch_requested_db_revision);\r
220 +\r
221      notmuch_process_shared_options (argv[0]);\r
222  \r
223      if (notmuch_config_is_new (config))\r
224 diff --git a/notmuch-show.c b/notmuch-show.c\r
225 index 3917b82..de16db3 100644\r
226 --- a/notmuch-show.c\r
227 +++ b/notmuch-show.c\r
228 @@ -1220,6 +1220,8 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])\r
229                                NOTMUCH_DATABASE_MODE_READ_ONLY, &notmuch))\r
230         return EXIT_FAILURE;\r
231  \r
232 +    notmuch_exit_if_unmatched_db_revision (notmuch);\r
233 +\r
234      query = notmuch_query_create (notmuch, query_string);\r
235      if (query == NULL) {\r
236         fprintf (stderr, "Out of memory\n");\r
237 diff --git a/notmuch-tag.c b/notmuch-tag.c\r
238 index 35f971d..2c54eec 100644\r
239 --- a/notmuch-tag.c\r
240 +++ b/notmuch-tag.c\r
241 @@ -261,6 +261,8 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[])\r
242                                NOTMUCH_DATABASE_MODE_READ_WRITE, &notmuch))\r
243         return EXIT_FAILURE;\r
244  \r
245 +    notmuch_exit_if_unmatched_db_revision (notmuch);\r
246 +\r
247      if (notmuch_config_get_maildir_synchronize_flags (config))\r
248         tag_flags |= TAG_FLAG_MAILDIR_SYNC;\r
249  \r
250 diff --git a/notmuch.c b/notmuch.c\r
251 index c7f8c8f..90e6de3 100644\r
252 --- a/notmuch.c\r
253 +++ b/notmuch.c\r
254 @@ -47,10 +47,12 @@ static int\r
255  _help_for (const char *topic);\r
256  \r
257  static notmuch_bool_t print_version = FALSE, print_help = FALSE;\r
258 +char *notmuch_requested_db_revision = NULL;\r
259  \r
260  const notmuch_opt_desc_t notmuch_shared_options [] = {\r
261      { NOTMUCH_OPT_BOOLEAN, &print_version, "version", 'v', 0 },\r
262      { NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 },\r
263 +    { NOTMUCH_OPT_STRING, &notmuch_requested_db_revision, "db-revision", 'd', 0 },\r
264      {0, 0, 0, 0, 0}\r
265  };\r
266  \r
267 @@ -196,6 +198,22 @@ be supported in the future.\n", notmuch_format_version);\r
268      }\r
269  }\r
270  \r
271 +void\r
272 +notmuch_exit_if_unmatched_db_revision (notmuch_database_t *notmuch)\r
273 +{\r
274 +    const char *uuid = NULL;\r
275 +\r
276 +    if (!notmuch_requested_db_revision)\r
277 +       return;\r
278 +    IGNORE_RESULT (notmuch_database_get_revision (notmuch, &uuid));\r
279 +\r
280 +    if (strcmp (notmuch_requested_db_revision, uuid) != 0){\r
281 +       fprintf (stderr, "Error: requested database revision %s does not match %s\n",\r
282 +                notmuch_requested_db_revision, uuid);\r
283 +       exit (1);\r
284 +    }\r
285 +}\r
286 +\r
287  static void\r
288  exec_man (const char *page)\r
289  {\r
290 -- \r
291 2.1.4\r
292 \r