--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\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 741E0431FAF\r
+ for <notmuch@notmuchmail.org>; Thu, 6 Mar 2014 12:58:45 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ 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 ofvF25MBpADm for <notmuch@notmuchmail.org>;\r
+ Thu, 6 Mar 2014 12:58:39 -0800 (PST)\r
+Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com\r
+ [74.125.82.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 53EDE431FAE for <notmuch@notmuchmail.org>; Thu, 6 Mar 2014 12:58:39 -0800\r
+ (PST)\r
+Received: by mail-wg0-f46.google.com with SMTP id z12so3917701wgg.5\r
+ for <notmuch@notmuchmail.org>; Thu, 06 Mar 2014 12:58:36 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id;\r
+ bh=2gvtUeMD6hLOWIgRiBnbjBv7NRaXCD1KXqCV/oEwoAo=;\r
+ b=XmX3v5g5g5FU1Frkw0VuSscgsH40u4RuOXnGP8Yor1OvWd25myUu7jrPCDNDbChm4W\r
+ r39JeJB+JOPyh/8PM9SQQzeZWuWiNnbC2Nbtk8fjPg8XAZ1x2LD6VBj3FLnnLu1m87ww\r
+ qRH0ym9AjJLhUQ02oVhTYnRSV5HPD0psRR/morz3JABIazRwjvgXxiCEoGT1yAQj5QGu\r
+ oa3Rjzlca+nwq4LhCq0+BhmTQRUKTQRehTtYNctkbLwss3tPJg4IvRlHKF5MUBJ7DpOG\r
+ 475cA4Sj4pi7MqyB8lmYFqJ0IPe7Bf3+OBlaolGw+qAwW7fAOEy8F5q/EfVzWrSqA8+p\r
+ azPQ==\r
+X-Received: by 10.194.143.82 with SMTP id sc18mr13582706wjb.11.1394139515294; \r
+ Thu, 06 Mar 2014 12:58:35 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+ by mx.google.com with ESMTPSA id z1sm22809906wjq.19.2014.03.06.12.58.34\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Thu, 06 Mar 2014 12:58:34 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] notmuch new: add a --in-directory option\r
+Date: Thu, 6 Mar 2014 20:58:27 +0000\r
+Message-Id: <1394139507-15324-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\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 20:58:45 -0000\r
+\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
+-- \r
+1.7.9.1\r
+\r