--- /dev/null
+Return-Path: <jani@nikula.org>\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 816D2431FD6\r
+ for <notmuch@notmuchmail.org>; Sun, 23 Feb 2014 14:22:24 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 3wycUm3baTpm for <notmuch@notmuchmail.org>;\r
+ Sun, 23 Feb 2014 14:22:15 -0800 (PST)\r
+Received: from mail-ee0-f51.google.com (mail-ee0-f51.google.com\r
+ [74.125.83.51]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 2196E431FCF for <notmuch@notmuchmail.org>; Sun, 23 Feb 2014 14:22:15 -0800\r
+ (PST)\r
+Received: by mail-ee0-f51.google.com with SMTP id b57so2772311eek.24\r
+ for <notmuch@notmuchmail.org>; Sun, 23 Feb 2014 14:22:12 -0800 (PST)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:in-reply-to:references\r
+ :user-agent:date:message-id:mime-version:content-type;\r
+ bh=bOHTjL7f0i3cgmPvbIjdEDHqj6hW7DLI9abvLBhb0os=;\r
+ b=h702OTZN6zGQ/o0ntFKjPdr8KDeFOY1K3PpABWW6l7gest/6MTk3cfOy8bIqeDpK7H\r
+ P/STHExxG9vQ4ammz6P1R0qKVRKSzcfChrCo8k06lj6FfxFF/N0FvSLhi4zeM//CV+mZ\r
+ aApT6Rvktm4eyzK7Fur7ESY0cqfl1JxYBMSUn5WZjeDj/dyvvuuedGEmoNbkPHvUwbeL\r
+ 4zyzoEr3j5fPDnUewQbI3wdH7Vusu2ySGn8fQn/l6S26RhIPPbjCN2Vjij0kb4P3lFn4\r
+ o6rpIs09dBAsJ3+AYQcJJE53mmV1CBgyU/nPBNr/8anVLN5IqySajy1c+P5f9IgKwsh7\r
+ fpcw==\r
+X-Gm-Message-State:\r
+ ALoCoQmf+YlgnuVpSV81WyilYP/jaDsNAHwst/bRkrZ8TIQ3z/T8Kl8S5Z+l7H7eBxKDNWWo3bJX\r
+X-Received: by 10.14.221.201 with SMTP id r49mr21126016eep.104.1393194132605; \r
+ Sun, 23 Feb 2014 14:22:12 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+ [88.195.111.91])\r
+ by mx.google.com with ESMTPSA id q44sm56081208eez.1.2014.02.23.14.22.11\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sun, 23 Feb 2014 14:22:11 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
+Subject: Re: [DRAFT PATCH] notmuch new: do not ignore '.notmuch' in\r
+ non-toplevel directories\r
+In-Reply-To: <1393183127-31869-1-git-send-email-tomi.ollila@iki.fi>\r
+References: <87mwhifu9a.fsf@trouble.defaultvalue.org>\r
+ <1393183127-31869-1-git-send-email-tomi.ollila@iki.fi>\r
+User-Agent: Notmuch/0.17+44~ge3b4cd9 (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Mon, 24 Feb 2014 00:22:10 +0200\r
+Message-ID: <87ios5v59p.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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 22:22:24 -0000\r
+\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