From: Mark Walters Date: Thu, 6 Mar 2014 20:58:27 +0000 (+0000) Subject: [PATCH] notmuch new: add a --in-directory option X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3884ba0c73a9aa651a7bed6e7ca3020e262e846c;p=notmuch-archives.git [PATCH] notmuch new: add a --in-directory option --- diff --git a/56/38885e67752dd59b3a3305daae19c2fe883865 b/56/38885e67752dd59b3a3305daae19c2fe883865 new file mode 100644 index 000000000..4cf500bf9 --- /dev/null +++ b/56/38885e67752dd59b3a3305daae19c2fe883865 @@ -0,0 +1,136 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 741E0431FAF + for ; Thu, 6 Mar 2014 12:58:45 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id ofvF25MBpADm for ; + Thu, 6 Mar 2014 12:58:39 -0800 (PST) +Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com + [74.125.82.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 53EDE431FAE for ; Thu, 6 Mar 2014 12:58:39 -0800 + (PST) +Received: by mail-wg0-f46.google.com with SMTP id z12so3917701wgg.5 + for ; Thu, 06 Mar 2014 12:58:36 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id; + bh=2gvtUeMD6hLOWIgRiBnbjBv7NRaXCD1KXqCV/oEwoAo=; + b=XmX3v5g5g5FU1Frkw0VuSscgsH40u4RuOXnGP8Yor1OvWd25myUu7jrPCDNDbChm4W + r39JeJB+JOPyh/8PM9SQQzeZWuWiNnbC2Nbtk8fjPg8XAZ1x2LD6VBj3FLnnLu1m87ww + qRH0ym9AjJLhUQ02oVhTYnRSV5HPD0psRR/morz3JABIazRwjvgXxiCEoGT1yAQj5QGu + oa3Rjzlca+nwq4LhCq0+BhmTQRUKTQRehTtYNctkbLwss3tPJg4IvRlHKF5MUBJ7DpOG + 475cA4Sj4pi7MqyB8lmYFqJ0IPe7Bf3+OBlaolGw+qAwW7fAOEy8F5q/EfVzWrSqA8+p + azPQ== +X-Received: by 10.194.143.82 with SMTP id sc18mr13582706wjb.11.1394139515294; + Thu, 06 Mar 2014 12:58:35 -0800 (PST) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id z1sm22809906wjq.19.2014.03.06.12.58.34 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Thu, 06 Mar 2014 12:58:34 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH] notmuch new: add a --in-directory option +Date: Thu, 6 Mar 2014 20:58:27 +0000 +Message-Id: <1394139507-15324-1-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Thu, 06 Mar 2014 20:58:45 -0000 + +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 +