--- /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 01BC6431FAF\r
+ for <notmuch@notmuchmail.org>; Thu, 6 Mar 2014 13:06:33 -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 91RJWhfdfZhp for <notmuch@notmuchmail.org>;\r
+ Thu, 6 Mar 2014 13:06:27 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-7.mit.edu (dmz-mailsec-scanner-7.mit.edu\r
+ [18.7.68.36])\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 61B75431FAE\r
+ for <notmuch@notmuchmail.org>; Thu, 6 Mar 2014 13:06:27 -0800 (PST)\r
+X-AuditID: 12074424-f79e26d000000c70-a7-5318e352716d\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ (using TLS with cipher AES256-SHA (256/256 bits))\r
+ (Client did not present a certificate)\r
+ by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 45.0F.03184.253E8135; Thu, 6 Mar 2014 16:06:26 -0500 (EST)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id s26L6PxD009277; \r
+ Thu, 6 Mar 2014 16:06:26 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+ (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s26L6MmV024989\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+ Thu, 6 Mar 2014 16:06:24 -0500\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1WLfUk-0003PV-Ox; Thu, 06 Mar 2014 16:06:22 -0500\r
+Date: Thu, 6 Mar 2014 16:06:22 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Mark Walters <markwalters1009@gmail.com>\r
+Subject: Re: [PATCH] notmuch new: add a --in-directory option\r
+Message-ID: <20140306210622.GI4709@mit.edu>\r
+References: <1394139507-15324-1-git-send-email-markwalters1009@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <1394139507-15324-1-git-send-email-markwalters1009@gmail.com>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IRYrdT1w16LBFs0P9GyWL1XB6L6zdnMjsw\r
+ eeycdZfd49mqW8wBTFFcNimpOZllqUX6dglcGR/6VjEXfBGvWHp2GlMDY4dwFyMnh4SAicTF\r
+ Q+tZIWwxiQv31rN1MXJxCAnMZpLYuO8XK4SzgVHi4PW1TBDOKSaJ/51boDJLGCUOb93ECNLP\r
+ IqAisfDoTrBZbAIaEtv2LweLiwjoSNw+tIAdxGYWkJb49ruZCcQWFrCV+P3gM1icV0BbYu31\r
+ XSwgtpCAp8Sxw/eZIOKCEidnPmGB6NWSuPHvJVCcA2zO8n8cIGFOAS+JX49OgpWLAp0w5eQ2\r
+ tgmMQrOQdM9C0j0LoXsBI/MqRtmU3Crd3MTMnOLUZN3i5MS8vNQiXXO93MwSvdSU0k2M4LB2\r
+ UdnB2HxI6RCjAAejEg9vxyKJYCHWxLLiytxDjJIcTEqivO4PgEJ8SfkplRmJxRnxRaU5qcWH\r
+ GCU4mJVEeI0PAuV4UxIrq1KL8mFS0hwsSuK8fWeBUgLpiSWp2ampBalFMFkZDg4lCV6zR0BZ\r
+ waLU9NSKtMycEoQ0EwcnyHAeoOFaIDW8xQWJucWZ6RD5U4yKUuK8viAJAZBERmkeXC8s7bxi\r
+ FAd6RZi3DKSKB5iy4LpfAQ1mAhoczScOMrgkESEl1cCY0lcotKg5Z+fqsNRXBgyPlC9Vz3qV\r
+ VnCqPethuGipu+ay4uJnzRKpyyaUByT/r5Bt3lH7/+Y22TcJFmclyqZ1Xr69fk4rf1x4QwY3\r
+ a7VYl9feZUZR3U/zFp5O7P32vJmxc9rJVfUH3n9+7Pk3fcrXpUfLt3zZYvb8vV+xgMP1kM+a\r
+ z6vZPb8osRRnJBpqMRcVJwIAfC45tRYDAAA=\r
+Cc: notmuch@notmuchmail.org\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: Thu, 06 Mar 2014 21:06:34 -0000\r
+\r
+I haven't thought about this as a patch yet, but wanted to point out\r
+that it should probably skip the removal step if it's only scanning a\r
+subdirectory. Otherwise, messages that are moved out of the scanned\r
+directory into some other may be considered deleted and get removed\r
+from the database.\r
+\r
+That aside, I'm curious what the use case for this is.\r
+\r
+Quoth Mark Walters on Mar 06 at 8:58 pm:\r
+> This patch adds a --in-directory=folder option to notmuch new which\r
+> tells it to only check for new messages inside folder (relative to the\r
+> database root)\r
+> ---\r
+> \r
+> NOTE This is only very lightly tested (but seems to work) so please\r
+> make sure you backup the notmuch database before testing!\r
+> \r
+> \r
+> notmuch-new.c | 10 +++++++++-\r
+> test/T050-new.sh | 15 +++++++++++++++\r
+> 2 files changed, 24 insertions(+), 1 deletions(-)\r
+> \r
+> diff --git a/notmuch-new.c b/notmuch-new.c\r
+> index 8529fdd..d3526ac 100644\r
+> --- a/notmuch-new.c\r
+> +++ b/notmuch-new.c\r
+> @@ -922,6 +922,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
+> notmuch_bool_t timer_is_active = FALSE;\r
+> notmuch_bool_t no_hooks = FALSE;\r
+> notmuch_bool_t quiet = FALSE, verbose = FALSE;\r
+> + char *directory = NULL;\r
+> + char *path = NULL;\r
+> \r
+> add_files_state.verbosity = VERBOSITY_NORMAL;\r
+> add_files_state.debug = FALSE;\r
+> @@ -932,6 +934,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
+> { NOTMUCH_OPT_BOOLEAN, &verbose, "verbose", 'v', 0 },\r
+> { NOTMUCH_OPT_BOOLEAN, &add_files_state.debug, "debug", 'd', 0 },\r
+> { NOTMUCH_OPT_BOOLEAN, &no_hooks, "no-hooks", 'n', 0 },\r
+> + { NOTMUCH_OPT_STRING, &directory, "in-directory", 'i', 0 },\r
+> { 0, 0, 0, 0, 0 }\r
+> };\r
+> \r
+> @@ -1021,7 +1024,12 @@ 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
+> + if (directory)\r
+> + path = talloc_asprintf (config, "%s/%s", db_path, directory);\r
+> + else\r
+> + path = talloc_strdup (config, db_path);\r
+> +\r
+> + ret = add_files (notmuch, path, &add_files_state);\r
+> if (ret)\r
+> goto DONE;\r
+> \r
+> diff --git a/test/T050-new.sh b/test/T050-new.sh\r
+> index b7668ff..b8e68a3 100755\r
+> --- a/test/T050-new.sh\r
+> +++ b/test/T050-new.sh\r
+> @@ -263,4 +263,19 @@ notmuch search --format=text0 --output=files --offset=1 --limit=1 '*' | xargs -0\r
+> output=$(NOTMUCH_NEW --quiet)\r
+> test_expect_equal "$output" ""\r
+> \r
+> +test_begin_subtest "In-directory"\r
+> +rm -rf "${MAIL_DIR}"/* "${MAIL_DIR}"/.notmuch\r
+> +mkdir "${MAIL_DIR}"/def\r
+> +mkdir "${MAIL_DIR}"/ghi\r
+> +generate_message [dir]=def\r
+> +generate_message [dir]=ghi\r
+> +generate_message\r
+> +\r
+> +output=$(NOTMUCH_NEW --in-directory=def)\r
+> +test_expect_equal "$output" "Added 1 new message to the database."\r
+> +\r
+> +test_begin_subtest "New after --in-directory"\r
+> +output=$(NOTMUCH_NEW)\r
+> +test_expect_equal "$output" "Added 2 new messages to the database."\r
+> +\r
+> test_done\r