Re: Applying patches directly from emails?
[notmuch-archives.git] / 7e / 503f6ed8435c609a384b0dff441408389d576f
1 Return-Path: <amdragon@mit.edu>\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 0149B429E34\r
6         for <notmuch@notmuchmail.org>; Wed,  1 Feb 2012 08:31:52 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id oAmebpKagPhl for <notmuch@notmuchmail.org>;\r
16         Wed,  1 Feb 2012 08:31:51 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
18         [18.9.25.14])\r
19         by olra.theworths.org (Postfix) with ESMTP id 9AC2B431E64\r
20         for <notmuch@notmuchmail.org>; Wed,  1 Feb 2012 08:31:51 -0800 (PST)\r
21 X-AuditID: 1209190e-b7f7c6d0000008c3-98-4f2968f78472\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
23         by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 61.C8.02243.7F8692F4; Wed,  1 Feb 2012 11:31:51 -0500 (EST)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q11GVoqT004266; \r
27         Wed, 1 Feb 2012 11:31:51 -0500\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q11GVmIb008656\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Wed, 1 Feb 2012 11:31:49 -0500 (EST)\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1Rsd5A-00062D-7e; Wed, 01 Feb 2012 11:30:52 -0500\r
37 Date: Wed, 1 Feb 2012 11:30:52 -0500\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: Tomi Ollila <tomi.ollila@iki.fi>\r
40 Subject: Re: [PATCH] added support for user-specified files & directories to\r
41         ignore\r
42 Message-ID: <20120201163052.GG10898@mit.edu>\r
43 References: <1315949524-4948-1-git-send-email-tomi.ollila@iki.fi>\r
44         <20120131-new-ignore-1-git-send-email-too@iki.fi>\r
45 MIME-Version: 1.0\r
46 Content-Type: text/plain; charset=us-ascii\r
47 Content-Disposition: inline\r
48 In-Reply-To: <20120131-new-ignore-1-git-send-email-too@iki.fi>\r
49 User-Agent: Mutt/1.5.21 (2010-09-15)\r
50 X-Brightmail-Tracker:\r
51  H4sIAAAAAAAAA+NgFmpgleLIzCtJLcpLzFFi42IRYrdT1/2eoelv8HMmh8X1mzOZLd6snMfq\r
52         wORx+OtCFo9nq24xBzBFcdmkpOZklqUW6dslcGXcmyxZMCuwYu8/9wbGp3ZdjBwcEgImEs03\r
53         s7oYOYFMMYkL99azgdhCAvsYJSYvSOli5AKy1zNKrN22kxHCOcEkceXHPxYIZwmjxOO/RxlB\r
54         WlgEVCQ+v7/JDGKzCWhIbNu/HCwuAhR/0LaeFcRmFpCW+Pa7mQnEFhYIlejYdgKsnldAR2J/\r
55         33lmiNWlEhsenmeEiAtKnJz5hAWiV0vixr+XTCBXg8xZ/o8DJMwpYCex7NdtsHJRoFVTTm5j\r
56         m8AoNAtJ9ywk3bMQuhcwMq9ilE3JrdLNTczMKU5N1i1OTszLSy3SNdbLzSzRS00p3cQICmhO\r
57         Sb4djF8PKh1iFOBgVOLh3SWt4S/EmlhWXJl7iFGSg0lJlPdpqqa/EF9SfkplRmJxRnxRaU5q\r
58         8SFGCQ5mJRHeidFAOd6UxMqq1KJ8mJQ0B4uSOK+a1js/IYH0xJLU7NTUgtQimKwMB4eSBK8L\r
59         MHKFBItS01Mr0jJzShDSTBycIMN5gIZ7gNTwFhck5hZnpkPkTzEqSonzBoEkBEASGaV5cL2w\r
60         hPOKURzoFWHeuHSgKh5gsoLrfgU0mAloMIMF2OCSRISUVAOjxtFzd6aYnueLYL/kbWp4OWH6\r
61         /wv/MjW0bzmH1GxL5FvuvnXy1OTFp9hPVPxKa9qxdukypoprrLpsNocDFJ4nLi8TcN98+LmP\r
62         +alTzqczNx7tL6+cfsv5u2t0IsuP9WJsHezaPZu6FJfOVLkR7JZ+PL+Ys/0h+8bZT0/8SddJ\r
63         YVWKjdv/f7WZEktxRqKhFnNRcSIA2evvkxMDAAA=\r
64 Cc: notmuch@notmuchmail.org\r
65 X-BeenThere: notmuch@notmuchmail.org\r
66 X-Mailman-Version: 2.1.13\r
67 Precedence: list\r
68 List-Id: "Use and development of the notmuch mail system."\r
69         <notmuch.notmuchmail.org>\r
70 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
72 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
73 List-Post: <mailto:notmuch@notmuchmail.org>\r
74 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
75 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
76         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
77 X-List-Received-Date: Wed, 01 Feb 2012 16:31:53 -0000\r
78 \r
79 Quoth Tomi Ollila on Jan 31 at  6:28 pm:\r
80 > A new configuration key 'new.ignore' is used to determine which\r
81 > files and directories user wants not to be scanned as new mails.\r
82\r
83 > This work merges my previous attempts and Andreas Amann's work\r
84 > in id:"ylp7hi23mw8.fsf@tyndall.ie"\r
85\r
86 > See notes in id:"20120131-new-ignore-1-git-send-email-too@iki.fi"\r
87 > ---\r
88 > Notes\r
89\r
90 > 1) Currently there is comment for new.ignore in newly created configuration\r
91 > file but as the list is initially empty there will be not tag in place.\r
92\r
93 > 2) Whenever some already existing directory is added to the exclude list\r
94 > and the parent directory timestamp has not changed, notmuch new will not\r
95 > notice the directory has gone (as it still is there), user needs to 'touch'\r
96 > the parent directory before next 'notmuch new' no make notmuch notice.\r
97\r
98 > 2012-01-26: could notmuch track mtime of the configuration file and if\r
99 > that changes, ignore mail directory timestamps ?\r
100\r
101\r
102 > 3) in id:"1327572718-13411-2-git-send-email-tomi.ollila@iki.fi" dropped...\r
103\r
104 >  notmuch-client.h |    8 ++++++++\r
105 >  notmuch-config.c |   35 +++++++++++++++++++++++++++++++++--\r
106 >  notmuch-new.c    |   45 +++++++++++++++++++++++++++++++++------------\r
107 >  3 files changed, 74 insertions(+), 14 deletions(-)\r
108\r
109 > diff --git a/notmuch-client.h b/notmuch-client.h\r
110 > index e0eb594..c62ce78 100644\r
111 > --- a/notmuch-client.h\r
112 > +++ b/notmuch-client.h\r
113 > @@ -250,6 +250,14 @@ notmuch_config_set_new_tags (notmuch_config_t *config,\r
114 >                            const char *new_tags[],\r
115 >                            size_t length);\r
116 >  \r
117 > +const char **\r
118 > +notmuch_config_get_new_ignore (notmuch_config_t *config,\r
119 > +                            size_t *length);\r
120 \r
121 Missing blank line.\r
122 \r
123 > +void\r
124 > +notmuch_config_set_new_ignore (notmuch_config_t *config,\r
125 > +                            const char *new_ignore[],\r
126 > +                            size_t length);\r
127 > +\r
128 >  notmuch_bool_t\r
129 >  notmuch_config_get_maildir_synchronize_flags (notmuch_config_t *config);\r
130 >  \r
131 > diff --git a/notmuch-config.c b/notmuch-config.c\r
132 > index a124e34..f1cc5c2 100644\r
133 > --- a/notmuch-config.c\r
134 > +++ b/notmuch-config.c\r
135 > @@ -44,7 +44,10 @@ static const char new_config_comment[] =\r
136 >      " The following options are supported here:\n"\r
137 >      "\n"\r
138 >      "\ttags  A list (separated by ';') of the tags that will be\n"\r
139 > -    "\t      added to all messages incorporated by \"notmuch new\".\n";\r
140 > +    "\t      added to all messages incorporated by \"notmuch new\".\n"\r
141 > +    "\n"\r
142 > +    "\tignore        A list (separated by ';') of files and directories that"\r
143 > +    "\t      will not be searched for messages by \"notmuch new\".\n";\r
144 \r
145 This can be interpreted in a lot of ways (e.g., absolute paths, paths\r
146 relative to database.path, etc) but is expecting something very\r
147 specific.  Maybe "file and directory names"?\r
148 \r
149 >  \r
150 >  static const char user_config_comment[] =\r
151 >      " User configuration\n"\r
152 > @@ -105,6 +108,8 @@ struct _notmuch_config {\r
153 >      size_t user_other_email_length;\r
154 >      const char **new_tags;\r
155 >      size_t new_tags_length;\r
156 > +    const char **new_ignore;\r
157 > +    size_t new_ignore_length;\r
158 >      notmuch_bool_t maildir_synchronize_flags;\r
159 >      const char **search_exclude_tags;\r
160 >      size_t search_exclude_tags_length;\r
161 > @@ -264,6 +269,8 @@ notmuch_config_open (void *ctx,\r
162 >      config->user_other_email_length = 0;\r
163 >      config->new_tags = NULL;\r
164 >      config->new_tags_length = 0;\r
165 > +    config->new_ignore = NULL;\r
166 > +    config->new_ignore_length = 0;\r
167 >      config->maildir_synchronize_flags = TRUE;\r
168 >      config->search_exclude_tags = NULL;\r
169 >      config->search_exclude_tags_length = 0;\r
170 > @@ -360,7 +367,11 @@ notmuch_config_open (void *ctx,\r
171 >          const char *tags[] = { "unread", "inbox" };\r
172 >       notmuch_config_set_new_tags (config, tags, 2);\r
173 >      }\r
174 > -\r
175 \r
176 Looks like you lost a blank line.\r
177 \r
178 > +#if 0 /* No point setting empty list -- it's not written */\r
179 > +    if (notmuch_config_get_new_ignore (config, &tmp) == NULL) {\r
180 > +     notmuch_config_set_new_ignore (config, NULL, 0);\r
181 > +    }\r
182 > +#endif\r
183 \r
184 This *does* matter.  It affects whether or not this key appears in\r
185 saved configuration files (both updated ones and new ones).  For\r
186 discoverability's sake (especially since we don't have a way to update\r
187 the section's comment), it should appear, even though it's blank.\r
188 \r
189 (For the record, I think 'notmuch config set's behavior of removing a\r
190 key if given no arguments is broken; because of how we handle\r
191 defaults, this is completely asymmetric behavior, plus it seems to\r
192 screw up group comments.)\r
193 \r
194 Also, there should be another blank line after the if.\r
195 \r
196 >      if (notmuch_config_get_search_exclude_tags (config, &tmp) == NULL) {\r
197 >       if (is_new) {\r
198 >           const char *tags[] = { "deleted", "spam" };\r
199 > @@ -609,6 +620,15 @@ notmuch_config_get_new_tags (notmuch_config_t *config,   size_t *length)\r
200 >                            &(config->new_tags_length), length);\r
201 >  }\r
202 >  \r
203 > +const char **\r
204 > +notmuch_config_get_new_ignore (notmuch_config_t *config,   size_t *length)\r
205 > +{\r
206 > +    return _config_get_list (config, "new", "ignore",\r
207 > +                          &(config->new_ignore),\r
208 > +                          &(config->new_ignore_length), length);\r
209 > +}\r
210 > +\r
211 > +\r
212 \r
213 One extra blank line.\r
214 \r
215 >  void\r
216 >  notmuch_config_set_user_other_email (notmuch_config_t *config,\r
217 >                                    const char *list[],\r
218 > @@ -627,6 +647,17 @@ notmuch_config_set_new_tags (notmuch_config_t *config,\r
219 >                    &(config->new_tags));\r
220 >  }\r
221 >  \r
222 > +#if 0 /* UNNEEDED SO FAR */\r
223 \r
224 Include this, even if we don't need it.\r
225 \r
226 > +void\r
227 > +notmuch_config_set_new_ignore (notmuch_config_t *config,\r
228 > +                            const char *list[],\r
229 > +                            size_t length)\r
230 > +{\r
231 > +    _config_set_list (config, "new", "ignore", list, length,\r
232 > +                  &(config->new_ignore));\r
233 > +}\r
234 > +#endif\r
235 > +\r
236 >  const char **\r
237 >  notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t *length)\r
238 >  {\r
239 > diff --git a/notmuch-new.c b/notmuch-new.c\r
240 > index a569a54..36d5c5d 100644\r
241 > --- a/notmuch-new.c\r
242 > +++ b/notmuch-new.c\r
243 > @@ -39,6 +39,8 @@ typedef struct {\r
244 >      int verbose;\r
245 >      const char **new_tags;\r
246 >      size_t new_tags_length;\r
247 > +    const char **new_ignore;\r
248 > +    size_t new_ignore_length;\r
249 >  \r
250 >      int total_files;\r
251 >      int processed_files;\r
252 > @@ -181,6 +183,20 @@ _entries_resemble_maildir (struct dirent **entries, int count)\r
253 >      return 0;\r
254 >  }\r
255 >  \r
256 > +/* Check if user asked to ignore these files/directories */\r
257 > +\r
258 \r
259 No blank line.\r
260 \r
261 > +static int\r
262 \r
263 Could be notmuch_bool_t (and TRUE and FALSE below).  Up to you.\r
264 \r
265 > +_entry_in_ignore_list (const char *entry, add_files_state_t *state)\r
266 > +{\r
267 > +    size_t i, ignore_length = state->new_ignore_length;\r
268 > +\r
269 > +    for (i = 0; i < ignore_length; i++)\r
270 > +     if (strcmp (entry, state->new_ignore[i]) == 0)\r
271 > +         return 1;\r
272 > +\r
273 > +    return 0;\r
274 > +}\r
275 > +\r
276 >  /* Examine 'path' recursively as follows:\r
277 >   *\r
278 >   *   o Ask the filesystem for the mtime of 'path' (fs_mtime)\r
279 > @@ -320,15 +336,15 @@ add_files_recursive (notmuch_database_t *notmuch,\r
280 >       }\r
281 >  \r
282 >       /* Ignore special directories to avoid infinite recursion.\r
283 > -      * Also ignore the .notmuch directory and any "tmp" directory\r
284 > -      * that appears within a maildir.\r
285 > +      * Also ignore the .notmuch directory, any "tmp" directory\r
286 > +      * that appears within a maildir and files/directories\r
287 > +      * user have configured to be ignored.\r
288 \r
289 s/user have/the user has/\r
290 \r
291 >        */\r
292 > -     /* XXX: Eventually we'll want more sophistication to let the\r
293 > -      * user specify files to be ignored. */\r
294 >       if (strcmp (entry->d_name, ".") == 0 ||\r
295 >           strcmp (entry->d_name, "..") == 0 ||\r
296 >           (is_maildir && strcmp (entry->d_name, "tmp") == 0) ||\r
297 > -         strcmp (entry->d_name, ".notmuch") ==0)\r
298 > +         strcmp (entry->d_name, ".notmuch") == 0 ||\r
299 > +         _entry_in_ignore_list (entry->d_name, state))\r
300 \r
301 Ah, nice simplification.\r
302 \r
303 >       {\r
304 >           continue;\r
305 >       }\r
306 > @@ -369,6 +385,10 @@ add_files_recursive (notmuch_database_t *notmuch,\r
307 >  \r
308 >          entry = fs_entries[i];\r
309 >  \r
310 > +     /* Ignore files & directories user has configured to be ignored */\r
311 > +     if (_entry_in_ignore_list (entry->d_name, state))\r
312 > +         continue;\r
313 > +\r
314 >       /* Check if we've walked past any names in db_files or\r
315 >        * db_subdirs. If so, these have been deleted. */\r
316 >       while (notmuch_filenames_valid (db_files) &&\r
317 > @@ -648,7 +668,7 @@ add_files (notmuch_database_t *notmuch,\r
318 >   * initialized to zero by the top-level caller before calling\r
319 >   * count_files). */\r
320 >  static void\r
321 > -count_files (const char *path, int *count)\r
322 > +count_files (const char *path, int *count, add_files_state_t *state)\r
323 >  {\r
324 >      struct dirent *entry = NULL;\r
325 >      char *next;\r
326 > @@ -670,13 +690,13 @@ count_files (const char *path, int *count)\r
327 >          entry = fs_entries[i++];\r
328 >  \r
329 >       /* Ignore special directories to avoid infinite recursion.\r
330 > -      * Also ignore the .notmuch directory.\r
331 > +      * Also ignore the .notmuch directory and files/directories\r
332 > +      * user have configured to be ignored.\r
333 >        */\r
334 > -     /* XXX: Eventually we'll want more sophistication to let the\r
335 > -      * user specify files to be ignored. */\r
336 >       if (strcmp (entry->d_name, ".") == 0 ||\r
337 >           strcmp (entry->d_name, "..") == 0 ||\r
338 > -         strcmp (entry->d_name, ".notmuch") == 0)\r
339 > +         strcmp (entry->d_name, ".notmuch") == 0 ||\r
340 > +         _entry_in_ignore_list (entry->d_name, state))\r
341 >       {\r
342 >           continue;\r
343 >       }\r
344 > @@ -697,7 +717,7 @@ count_files (const char *path, int *count)\r
345 >               fflush (stdout);\r
346 >           }\r
347 >       } else if (S_ISDIR (st.st_mode)) {\r
348 > -         count_files (next, count);\r
349 > +         count_files (next, count, state);\r
350 >       }\r
351 >  \r
352 >       free (next);\r
353 > @@ -837,6 +857,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
354 >       return 1;\r
355 >  \r
356 >      add_files_state.new_tags = notmuch_config_get_new_tags (config, &add_files_state.new_tags_length);\r
357 > +    add_files_state.new_ignore = notmuch_config_get_new_ignore (config, &add_files_state.new_ignore_length);\r
358 >      add_files_state.synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);\r
359 >      db_path = notmuch_config_get_database_path (config);\r
360 >  \r
361 > @@ -852,7 +873,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
362 >       int count;\r
363 >  \r
364 >       count = 0;\r
365 > -     count_files (db_path, &count);\r
366 > +     count_files (db_path, &count, &add_files_state);\r
367 >       if (interrupted)\r
368 >           return 1;\r
369 >  \r