--- /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 arlo.cworth.org (Postfix) with ESMTP id A934D6DE0C3A\r
+ for <notmuch@notmuchmail.org>; Fri, 25 Sep 2015 13:49:21 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.156\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.156 tagged_above=-999 required=5\r
+ tests=[AWL=-0.180, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01,\r
+ RCVD_IN_MSPIKE_WL=-0.01, URIBL_SBL=0.644, URIBL_SBL_A=0.1]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id ydWVKpyAWAh9 for <notmuch@notmuchmail.org>;\r
+ Fri, 25 Sep 2015 13:49:20 -0700 (PDT)\r
+Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
+ [209.85.212.181])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 28D7A6DE1216\r
+ for <notmuch@notmuchmail.org>; Fri, 25 Sep 2015 13:49:12 -0700 (PDT)\r
+Received: by wicge5 with SMTP id ge5so36252877wic.0\r
+ for <notmuch@notmuchmail.org>; Fri, 25 Sep 2015 13:49:10 -0700 (PDT)\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:date:message-id:in-reply-to\r
+ :references:in-reply-to:references;\r
+ bh=ACYfOSYsYDvgwOI+5WUrSlr9NJzVF1jHSbab53uAx4o=;\r
+ b=QrUWqJ7cuvnzJBC6A1HT2KxNzC0vSa7f29KgYAvv1dplG3hZVFJ6Bf5LAI/MJzznJT\r
+ 0EcNzAzPXfMmONcPFzzSlZLowtcBjGWMi6vk2a2qBamp4uZYoerCe9N5BCrUzlfLIR7m\r
+ 8zDfZkkj6mzg4oPwaAhlUH2bbhfOrCxmJ390S1dim739d72wEa0R2xUJvmPpm3w191Oa\r
+ CgEBek5X5fq6/D7+1IKyIzA7QIiz2/eIEAVC34dvqfrhpRFVOex/OwCbFFiPSLJ6C9t8\r
+ mPAIsKts23Kc4/5SOhAsH5bu9ICumaDf6ytk2o8Gqg1Os/ghVpsTI6pU6MoVFDv2rDUd\r
+ Ooxw==\r
+X-Gm-Message-State:\r
+ ALoCoQmGFchM6k212xkGNsDuQwVr5fjZr/8wWqe7QVj5zqkJw3Hf808xzdUJzQ+gmAMhfYHxuITF\r
+X-Received: by 10.180.102.226 with SMTP id fr2mr5876914wib.3.1443214150663;\r
+ Fri, 25 Sep 2015 13:49:10 -0700 (PDT)\r
+Received: from localhost (mobile-access-bcee63-221.dhcp.inet.fi.\r
+ [188.238.99.221])\r
+ by smtp.gmail.com with ESMTPSA id lj12sm4997002wic.0.2015.09.25.13.49.09\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Fri, 25 Sep 2015 13:49:10 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/3] cli: delete directory documents on directory removal\r
+Date: Fri, 25 Sep 2015 23:48:46 +0300\r
+Message-Id:\r
+ <591f5298ac3f2c79f727cac8bad1251830b28a3c.1443213654.git.jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <cover.1443213654.git.jani@nikula.org>\r
+References: <cover.1443213654.git.jani@nikula.org>\r
+In-Reply-To: <cover.1443213654.git.jani@nikula.org>\r
+References: <cover.1443213654.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\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: Fri, 25 Sep 2015 20:49:21 -0000\r
+\r
+There was a problem with the directory documents being left behind\r
+when the filesystem directory was removed. This was worked around in\r
+\r
+commit acd66cdec075312944e527febd46382e54d99367\r
+Author: Jani Nikula <jani@nikula.org>\r
+Date: Sat Sep 5 12:35:31 2015 +0300\r
+\r
+ cli: reset db directory mtime upon directory removal\r
+\r
+However, that ignored the fact that the directory documents are also\r
+still listed by notmuch_directory_get_child_directories() leading to\r
+confusing results when running notmuch new. The directory documents\r
+are found and queued for removal over and over again.\r
+\r
+Fix the problem for real by removing the directory documents. This\r
+fixes the tests flagged as broken in\r
+\r
+commit ed9ceda623d3f22fb66365b33db63c5c982067d3\r
+Author: David Bremner <david@tethera.net>\r
+Date: Tue Aug 4 08:48:34 2015 +0200\r
+\r
+ test: add debugging output to notmuch-new tests, mark 5 as broken\r
+\r
+The (non-deterministic) hack test from [1] also still passes with this\r
+change.\r
+\r
+[1] id:1441445731-4362-1-git-send-email-jani@nikula.org\r
+---\r
+ notmuch-new.c | 12 +++---------\r
+ 1 file changed, 3 insertions(+), 9 deletions(-)\r
+\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index 33645349cd5f..8bfed37fef96 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -878,17 +878,11 @@ _remove_directory (void *ctx,\r
+ goto DONE;\r
+ }\r
+ \r
+- /*\r
+- * XXX: The library does not have a function to remove a directory\r
+- * document for a path. Usually this doesn't matter except for a\r
+- * slight waste of space. However, if the directory gets added to\r
+- * the filesystem again, the old directory document is found with\r
+- * the old mtime. Reset the directory mtime to avoid problems.\r
+- */\r
+- notmuch_directory_set_mtime (directory, 0);\r
++ status = notmuch_directory_delete (directory);\r
+ \r
+ DONE:\r
+- notmuch_directory_destroy (directory);\r
++ if (status)\r
++ notmuch_directory_destroy (directory);\r
+ return status;\r
+ }\r
+ \r
+-- \r
+2.1.4\r
+\r