--- /dev/null
+Return-Path: <m.walters@qmul.ac.uk>\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 CA11E431FBF\r
+ for <notmuch@notmuchmail.org>; Sat, 1 Mar 2014 02:00:14 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+ tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+ NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 OeoWUdyuwoQD for <notmuch@notmuchmail.org>;\r
+ Sat, 1 Mar 2014 02:00:07 -0800 (PST)\r
+Received: from mail1.qmul.ac.uk (mail1.qmul.ac.uk [138.37.6.7])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 17C75431FAF\r
+ for <notmuch@notmuchmail.org>; Sat, 1 Mar 2014 02:00:07 -0800 (PST)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+ by mail1.qmul.ac.uk with esmtp (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1WJghy-0001FF-GD; Sat, 01 Mar 2014 09:59:54 +0000\r
+Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
+ by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1WJghy-0000Pz-5N; Sat, 01 Mar 2014 09:59:50 +0000\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Jani Nikula <jani@nikula.org>, Tomi Ollila <tomi.ollila@iki.fi>,\r
+ notmuch@notmuchmail.org\r
+Subject: Re: [DRAFT PATCH] notmuch new: do not ignore '.notmuch' in\r
+ non-toplevel directories\r
+In-Reply-To: <87ios5v59p.fsf@nikula.org>\r
+References: <87mwhifu9a.fsf@trouble.defaultvalue.org>\r
+ <1393183127-31869-1-git-send-email-tomi.ollila@iki.fi>\r
+ <87ios5v59p.fsf@nikula.org>\r
+User-Agent: Notmuch/0.15.2+562~g339f306 (http://notmuchmail.org) Emacs/23.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Sat, 01 Mar 2014 09:59:49 +0000\r
+Message-ID: <87r46mgrxm.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 93.97.24.31\r
+X-QM-Geographic: According to ripencc,\r
+ this message was delivered by a machine in Britain (UK) (GB).\r
+X-QM-SPAM-Info: Sender has good ham record. :)\r
+X-QM-Body-MD5: 1d30acd25db47e7da29da32f9c3df73d (of first 20000 bytes)\r
+X-SpamAssassin-Score: 0.0\r
+X-SpamAssassin-SpamBar: /\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+ determine if it is\r
+ spam. We require at least 5.0 points to mark a message as spam.\r
+ This message scored 0.0 points. Summary of the scoring: \r
+ * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+ provider * (markwalters1009[at]gmail.com)\r
+ * 0.0 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\r
+Cc: tomi.ollila@iki.fi\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: Sat, 01 Mar 2014 10:00:15 -0000\r
+\r
+\r
+An alternative would be to ignore any .notmuch path with a xapian\r
+sub-directory. This would mean if a user indexed some subset of their\r
+mail before trying to index the whole thing they wouldn't accidentally\r
+index the old xapian database. \r
+\r
+Alternatively we could just view the above as user error. (If a user\r
+wanted to have an index for a sub-directory they would have to use\r
+excludes to exclude that index from the full-directory index).\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+I think the above was suggested by rlb on irc but I don't think it got\r
+any reply. \r
+\r
+\r
+\r
+On Sun, 23 Feb 2014, Jani Nikula <jani@nikula.org> wrote:\r
+> On Sun, 23 Feb 2014, Tomi Ollila <tomi.ollila@iki.fi> wrote:\r
+>> So that users may have email in subdir/.notmuch directories.\r
+>> ---\r
+>>\r
+>> Compiles, current tests pass. might ignore database_path/.notmuch and\r
+>> might descent into database_path/.../.notmuch :D\r
+>>\r
+>> Tomi\r
+>>\r
+>>\r
+>> notmuch-new.c | 18 ++++++++++--------\r
+>> 1 file changed, 10 insertions(+), 8 deletions(-)\r
+>>\r
+>> diff --git a/notmuch-new.c b/notmuch-new.c\r
+>> index 8529fdd..b17bd75 100644\r
+>> --- a/notmuch-new.c\r
+>> +++ b/notmuch-new.c\r
+>> @@ -344,7 +344,8 @@ add_file (notmuch_database_t *notmuch, const char *filename,\r
+>> static notmuch_status_t\r
+>> add_files (notmuch_database_t *notmuch,\r
+>> const char *path,\r
+>> - add_files_state_t *state)\r
+>> + add_files_state_t *state,\r
+>> + int dirlevel)\r
+>\r
+> I think this is ugly and makes the interface harder to use for indexing\r
+> arbitrary paths.\r
+>\r
+> Instead, I suggest\r
+>\r
+> diff --git a/notmuch-new.c b/notmuch-new.c\r
+> index 8529fdd3eac7..20bc33fca4bd 100644\r
+> --- a/notmuch-new.c\r
+> +++ b/notmuch-new.c\r
+> @@ -469,7 +469,8 @@ add_files (notmuch_database_t *notmuch,\r
+> if (strcmp (entry->d_name, ".") == 0 ||\r
+> strcmp (entry->d_name, "..") == 0 ||\r
+> (is_maildir && strcmp (entry->d_name, "tmp") == 0) ||\r
+> - strcmp (entry->d_name, ".notmuch") == 0)\r
+> + (strcmp (entry->d_name, ".notmuch") == 0 &&\r
+> + strcmp (path, notmuch_database_get_path (notmuch)) == 0))\r
+> continue;\r
+> \r
+> next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);\r
+>\r
+> And similarly in count_files(), with the root db path passed as first\r
+> argument (as the db is not open yet).\r
+>\r
+>\r
+> BR,\r
+> Jani.\r
+>\r
+>\r
+>\r
+>> {\r
+>> DIR *dir = NULL;\r
+>> struct dirent *entry = NULL;\r
+>> @@ -469,11 +470,11 @@ add_files (notmuch_database_t *notmuch,\r
+>> if (strcmp (entry->d_name, ".") == 0 ||\r
+>> strcmp (entry->d_name, "..") == 0 ||\r
+>> (is_maildir && strcmp (entry->d_name, "tmp") == 0) ||\r
+>> - strcmp (entry->d_name, ".notmuch") == 0)\r
+>> + (dirlevel == 0 && strcmp (entry->d_name, ".notmuch") == 0))\r
+>> continue;\r
+>> \r
+>> next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);\r
+>> - status = add_files (notmuch, next, state);\r
+>> + status = add_files (notmuch, next, state, dirlevel + 1);\r
+>> if (status) {\r
+>> ret = status;\r
+>> goto DONE;\r
+>> @@ -702,7 +703,8 @@ stop_progress_printing_timer (void)\r
+>> * initialized to zero by the top-level caller before calling\r
+>> * count_files). */\r
+>> static void\r
+>> -count_files (const char *path, int *count, add_files_state_t *state)\r
+>> +count_files (const char *path, int *count, add_files_state_t *state,\r
+>> + int dirlevel)\r
+>> {\r
+>> struct dirent *entry = NULL;\r
+>> char *next;\r
+>> @@ -725,7 +727,7 @@ count_files (const char *path, int *count, add_files_state_t *state)\r
+>> */\r
+>> if (strcmp (entry->d_name, ".") == 0 ||\r
+>> strcmp (entry->d_name, "..") == 0 ||\r
+>> - strcmp (entry->d_name, ".notmuch") == 0 ||\r
+>> + (dirlevel == 0 && strcmp (entry->d_name, ".notmuch") == 0) ||\r
+>> _entry_in_ignore_list (entry->d_name, state))\r
+>> {\r
+>> if (state->debug && _entry_in_ignore_list (entry->d_name, state))\r
+>> @@ -750,7 +752,7 @@ count_files (const char *path, int *count, add_files_state_t *state)\r
+>> fflush (stdout);\r
+>> }\r
+>> } else if (entry_type == S_IFDIR) {\r
+>> - count_files (next, count, state);\r
+>> + count_files (next, count, state, dirlevel + 1);\r
+>> }\r
+>> \r
+>> free (next);\r
+>> @@ -962,7 +964,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
+>> int count;\r
+>> \r
+>> count = 0;\r
+>> - count_files (db_path, &count, &add_files_state);\r
+>> + count_files (db_path, &count, &add_files_state, 0);\r
+>> if (interrupted)\r
+>> return EXIT_FAILURE;\r
+>> \r
+>> @@ -1021,7 +1023,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
+>> timer_is_active = TRUE;\r
+>> }\r
+>> \r
+>> - ret = add_files (notmuch, db_path, &add_files_state);\r
+>> + ret = add_files (notmuch, db_path, &add_files_state, 0);\r
+>> if (ret)\r
+>> goto DONE;\r
+>> \r
+>> -- \r
+>> 1.8.4.2\r
+>>\r
+>> _______________________________________________\r
+>> notmuch mailing list\r
+>> notmuch@notmuchmail.org\r
+>> http://notmuchmail.org/mailman/listinfo/notmuch\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r