--- /dev/null
+Return-Path: <too@guru-group.fi>\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 021F9431FD6\r
+ for <notmuch@notmuchmail.org>; Sun, 23 Feb 2014 11:18:59 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ 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 pPXkDCG6riJQ for <notmuch@notmuchmail.org>;\r
+ Sun, 23 Feb 2014 11:18:55 -0800 (PST)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 65CDB431FCF\r
+ for <notmuch@notmuchmail.org>; Sun, 23 Feb 2014 11:18:55 -0800 (PST)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+ id A6987100086; Sun, 23 Feb 2014 21:18:49 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Subject: [DRAFT PATCH] notmuch new: do not ignore '.notmuch' in non-toplevel\r
+ directories\r
+Date: Sun, 23 Feb 2014 21:18:47 +0200\r
+Message-Id: <1393183127-31869-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 1.8.0\r
+In-Reply-To: <87mwhifu9a.fsf@trouble.defaultvalue.org>\r
+References: <87mwhifu9a.fsf@trouble.defaultvalue.org>\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: Sun, 23 Feb 2014 19:18:59 -0000\r
+\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
+ 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