--- /dev/null
+Return-Path: <amdragon@mit.edu>\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 1D91B429E36\r
+ for <notmuch@notmuchmail.org>; Thu, 17 May 2012 21:14:00 -0700 (PDT)\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 i0e7ZYrcKgjs for <notmuch@notmuchmail.org>;\r
+ Thu, 17 May 2012 21:13:58 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU\r
+ [18.9.25.15])\r
+ by olra.theworths.org (Postfix) with ESMTP id 7729A429E25\r
+ for <notmuch@notmuchmail.org>; Thu, 17 May 2012 21:13:53 -0700 (PDT)\r
+X-AuditID: 1209190f-b7f4f6d00000092b-3f-4fb5cc8052dc\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+ by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 38.3A.02347.08CC5BF4; Fri, 18 May 2012 00:13:52 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q4I4DqQN029944; \r
+ Fri, 18 May 2012 00:13:52 -0400\r
+Received: from drake.mit.edu\r
+ (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+ [209.6.116.242]) (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q4I4DoPQ026788\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Fri, 18 May 2012 00:13:51 -0400 (EDT)\r
+Received: from amthrax by drake.mit.edu with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1SVEZa-0000z9-Io; Fri, 18 May 2012 00:13:50 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 5/9] new: Remove workaround for detecting newly created\r
+ directory objects\r
+Date: Fri, 18 May 2012 00:13:38 -0400\r
+Message-Id: <1337314423-3702-6-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10\r
+In-Reply-To: <1337314423-3702-1-git-send-email-amdragon@mit.edu>\r
+References: <1337314423-3702-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsUixCmqrNtwZqu/weFvphbXb85kdmD0eLbq\r
+ FnMAYxSXTUpqTmZZapG+XQJXxrMvzcwFp6QrJj08wtrAOFu0i5GTQ0LARGLruSssELaYxIV7\r
+ 69m6GLk4hAT2MUqcbP3PCOFsYJRomjmZGcK5zySxdP0zFghnFqPEwpd9TCD9bAIaEtv2L2cE\r
+ sUUEpCV23p3N2sXIwcEsoCbxp0sFJCwsEClx89csZhCbRUBVovPVTVYQm1fAXuL/pmtQZ8hL\r
+ PL3fxwbSyingIDHteDRIWAio5N+FZpYJjPwLGBlWMcqm5Fbp5iZm5hSnJusWJyfm5aUW6Zro\r
+ 5WaW6KWmlG5iBAeNJP8Oxm8HlQ4xCnAwKvHw7piz1V+INbGsuDL3EKMkB5OSKO/3k0AhvqT8\r
+ lMqMxOKM+KLSnNTiQ4wSHMxKIryy3UA53pTEyqrUonyYlDQHi5I4r5rWOz8hgfTEktTs1NSC\r
+ 1CKYrAwHh5IEr8VpoEbBotT01Iq0zJwShDQTByfIcB6g4VogNbzFBYm5xZnpEPlTjIpS4rw2\r
+ IAkBkERGaR5cLyyqXzGKA70izBsKUsUDTAhw3a+ABjMBDS7L3QQyuCQRISXVwNiqb80Q17g1\r
+ Zf3xqetm/Qtgn9wx1UdDrDhi2d39Ktue6oT+nNruM+Pa7xmHvs0KSHado/f02iTThWGi8zYl\r
+ uW0/cue608cnUc83TpueaL/0xOlkw/KVvns8FdPeNopLalx7YLZp85z9W+avm/2698jb789W\r
+ LMy5GL9QWFjlYcqrfZ8e3rjc3X7gmhJLcUaioRZzUXEiACrcEnbFAgAA\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: Fri, 18 May 2012 04:14:00 -0000\r
+\r
+Previously, notmuch_database_get_directory did not indicate whether or\r
+not the returned directory object was newly created, which required a\r
+workaround to distinguish newly created directory objects with no\r
+child messages from directory objects that had no mtime set but did\r
+have child messages. Now that notmuch_database_get_directory\r
+distinguishes whether or not the directory object exists in the\r
+database, this workaround is no longer necessary.\r
+---\r
+ notmuch-new.c | 36 +++++++-----------------------------\r
+ 1 file changed, 7 insertions(+), 29 deletions(-)\r
+\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index a3a8bec..72dd558 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -256,7 +256,7 @@ add_files_recursive (notmuch_database_t *notmuch,\r
+ notmuch_filenames_t *db_subdirs = NULL;\r
+ time_t stat_time;\r
+ struct stat st;\r
+- notmuch_bool_t is_maildir, new_directory;\r
++ notmuch_bool_t is_maildir;\r
+ const char **tag;\r
+ \r
+ if (stat (path, &st)) {\r
+@@ -281,33 +281,12 @@ add_files_recursive (notmuch_database_t *notmuch,\r
+ }\r
+ db_mtime = directory ? notmuch_directory_get_mtime (directory) : 0;\r
+ \r
+- new_directory = db_mtime ? FALSE : TRUE;\r
+-\r
+- /* XXX This is a temporary workaround. If we don't update the\r
+- * database mtime until after processing messages in this\r
+- * directory, then a 0 mtime is *not* sufficient to indicate that\r
+- * this directory has no messages or subdirs in the database (for\r
+- * example, if an earlier run skipped the mtime update because\r
+- * fs_mtime == stat_time, or was interrupted before updating the\r
+- * mtime at the end). To address this, we record a (bogus)\r
+- * non-zero value before processing any child messages so that a\r
+- * later run won't mistake this for a new directory (and, for\r
+- * example, fail to detect removed files and subdirs).\r
+- *\r
+- * A better solution would be for notmuch_database_get_directory\r
+- * to indicate if it really created a new directory or not, either\r
+- * by a new out-argument, or by recording this information and\r
+- * providing an accessor.\r
+- */\r
+- if (new_directory && directory)\r
+- notmuch_directory_set_mtime (directory, -1);\r
+-\r
+ /* If the database knows about this directory, then we sort based\r
+ * on strcmp to match the database sorting. Otherwise, we can do\r
+ * inode-based sorting for faster filesystem operation. */\r
+ num_fs_entries = scandir (path, &fs_entries, 0,\r
+- new_directory ?\r
+- dirent_sort_inode : dirent_sort_strcmp_name);\r
++ directory ?\r
++ dirent_sort_strcmp_name : dirent_sort_inode);\r
+ \r
+ if (num_fs_entries == -1) {\r
+ fprintf (stderr, "Error opening directory %s: %s\n",\r
+@@ -376,13 +355,12 @@ add_files_recursive (notmuch_database_t *notmuch,\r
+ * being discovered until the clock catches up and the directory\r
+ * is modified again).\r
+ */\r
+- if (fs_mtime == db_mtime)\r
++ if (directory && fs_mtime == db_mtime)\r
+ goto DONE;\r
+ \r
+- /* new_directory means a directory that the database has never\r
+- * seen before. In that case, we can simply leave db_files and\r
+- * db_subdirs NULL. */\r
+- if (!new_directory) {\r
++ /* If the database has never seen this directory before, we can\r
++ * simply leave db_files and db_subdirs NULL. */\r
++ if (directory) {\r
+ db_files = notmuch_directory_get_child_files (directory);\r
+ db_subdirs = notmuch_directory_get_child_directories (directory);\r
+ }\r
+-- \r
+1.7.10\r
+\r