From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH] notmuch new: add a --in-directory option
Date: Thu, 6 Mar 2014 20:58:27 +0000 [thread overview]
Message-ID: <1394139507-15324-1-git-send-email-markwalters1009@gmail.com> (raw)
This patch adds a --in-directory=folder option to notmuch new which
tells it to only check for new messages inside folder (relative to the
database root)
---
NOTE This is only very lightly tested (but seems to work) so please
make sure you backup the notmuch database before testing!
notmuch-new.c | 10 +++++++++-
test/T050-new.sh | 15 +++++++++++++++
2 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/notmuch-new.c b/notmuch-new.c
index 8529fdd..d3526ac 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -922,6 +922,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
notmuch_bool_t timer_is_active = FALSE;
notmuch_bool_t no_hooks = FALSE;
notmuch_bool_t quiet = FALSE, verbose = FALSE;
+ char *directory = NULL;
+ char *path = NULL;
add_files_state.verbosity = VERBOSITY_NORMAL;
add_files_state.debug = FALSE;
@@ -932,6 +934,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
{ NOTMUCH_OPT_BOOLEAN, &verbose, "verbose", 'v', 0 },
{ NOTMUCH_OPT_BOOLEAN, &add_files_state.debug, "debug", 'd', 0 },
{ NOTMUCH_OPT_BOOLEAN, &no_hooks, "no-hooks", 'n', 0 },
+ { NOTMUCH_OPT_STRING, &directory, "in-directory", 'i', 0 },
{ 0, 0, 0, 0, 0 }
};
@@ -1021,7 +1024,12 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
timer_is_active = TRUE;
}
- ret = add_files (notmuch, db_path, &add_files_state);
+ if (directory)
+ path = talloc_asprintf (config, "%s/%s", db_path, directory);
+ else
+ path = talloc_strdup (config, db_path);
+
+ ret = add_files (notmuch, path, &add_files_state);
if (ret)
goto DONE;
diff --git a/test/T050-new.sh b/test/T050-new.sh
index b7668ff..b8e68a3 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -263,4 +263,19 @@ notmuch search --format=text0 --output=files --offset=1 --limit=1 '*' | xargs -0
output=$(NOTMUCH_NEW --quiet)
test_expect_equal "$output" ""
+test_begin_subtest "In-directory"
+rm -rf "${MAIL_DIR}"/* "${MAIL_DIR}"/.notmuch
+mkdir "${MAIL_DIR}"/def
+mkdir "${MAIL_DIR}"/ghi
+generate_message [dir]=def
+generate_message [dir]=ghi
+generate_message
+
+output=$(NOTMUCH_NEW --in-directory=def)
+test_expect_equal "$output" "Added 1 new message to the database."
+
+test_begin_subtest "New after --in-directory"
+output=$(NOTMUCH_NEW)
+test_expect_equal "$output" "Added 2 new messages to the database."
+
test_done
--
1.7.9.1
next reply other threads:[~2014-03-06 20:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-06 20:58 Mark Walters [this message]
2014-03-06 21:06 ` [PATCH] notmuch new: add a --in-directory option Austin Clements
2014-03-06 21:16 ` Adam Wolfe Gordon
2014-03-07 11:53 ` Tomi Ollila
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1394139507-15324-1-git-send-email-markwalters1009@gmail.com \
--to=markwalters1009@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).