--- /dev/null
+Return-Path: <bremner@tesseract.cs.unb.ca>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 4C0DF6DE17E8\r
+ for <notmuch@notmuchmail.org>; Fri, 5 Jun 2015 10:31:27 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.236\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.236 tagged_above=-999 required=5 tests=[AWL=0.226, \r
+ T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id hUTH_VJ9YrIY for <notmuch@notmuchmail.org>;\r
+ Fri, 5 Jun 2015 10:31:25 -0700 (PDT)\r
+Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
+ [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 632A56DE179F\r
+ for <notmuch@notmuchmail.org>; Fri, 5 Jun 2015 10:31:15 -0700 (PDT)\r
+Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
+ 4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+ id 1Z0vRx-0002oA-F6; Fri, 05 Jun 2015 17:30:33 +0000\r
+Received: (nullmailer pid 24254 invoked by uid 1000); Fri, 05 Jun 2015\r
+ 17:28:42 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 4/6] cli/count: add --output=modifications\r
+Date: Fri, 5 Jun 2015 19:28:36 +0200\r
+Message-Id: <1433525318-23756-5-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1433525318-23756-1-git-send-email-david@tethera.net>\r
+References: <1432936375-astroid-4-0i1n6yczs2-1520@strange>\r
+ <1433525318-23756-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\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, 05 Jun 2015 17:31:27 -0000\r
+\r
+We need some way to extract the uuid/revision of the database, and\r
+count seems like the least bad choice of current commands.\r
+The (perhaps weak) argument for count over search is that count\r
+already reports statistics about the entire database.\r
+---\r
+ notmuch-count.c | 18 +++++++++++++++++-\r
+ test/T570-revision-tracking.sh | 12 ++++++++++++\r
+ 2 files changed, 29 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/notmuch-count.c b/notmuch-count.c\r
+index 57a88a8..7c61ccb 100644\r
+--- a/notmuch-count.c\r
++++ b/notmuch-count.c\r
+@@ -25,6 +25,7 @@ enum {\r
+ OUTPUT_THREADS,\r
+ OUTPUT_MESSAGES,\r
+ OUTPUT_FILES,\r
++ OUTPUT_LASTMOD,\r
+ };\r
+ \r
+ /* The following is to allow future options to be added more easily */\r
+@@ -71,6 +72,9 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
+ {\r
+ notmuch_query_t *query;\r
+ size_t i;\r
++ unsigned long revision;\r
++ const char *uuid;\r
++ int ret = 0;\r
+ \r
+ query = notmuch_query_create (notmuch, query_str);\r
+ if (query == NULL) {\r
+@@ -91,11 +95,22 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
+ case OUTPUT_FILES:\r
+ printf ("%u\n", count_files (query));\r
+ break;\r
++ case OUTPUT_LASTMOD:\r
++ if (strcmp (notmuch_query_get_query_string (query), "*") != 0) {\r
++ fprintf (stderr, "Error: Only '*' is currently supported "\r
++ " with output=modifications\n");\r
++ ret = 1;\r
++ goto DONE;\r
++ }\r
++\r
++ revision = notmuch_database_get_revision (notmuch, &uuid);\r
++ printf ("%s\t%lu\n", uuid, revision);\r
+ }\r
+ \r
++ DONE:\r
+ notmuch_query_destroy (query);\r
+ \r
+- return 0;\r
++ return ret;\r
+ }\r
+ \r
+ static int\r
+@@ -139,6 +154,7 @@ notmuch_count_command (notmuch_config_t *config, int argc, char *argv[])\r
+ (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS },\r
+ { "messages", OUTPUT_MESSAGES },\r
+ { "files", OUTPUT_FILES },\r
++ { "modifications", OUTPUT_LASTMOD },\r
+ { 0, 0 } } },\r
+ { NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x',\r
+ (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },\r
+diff --git a/test/T570-revision-tracking.sh b/test/T570-revision-tracking.sh\r
+index 74a7c49..062fd59 100755\r
+--- a/test/T570-revision-tracking.sh\r
++++ b/test/T570-revision-tracking.sh\r
+@@ -34,4 +34,16 @@ UUID 53\r
+ EOF\r
+ test_expect_equal_file EXPECTED CLEAN\r
+ \r
++grep '^[0-9a-f]' OUTPUT > INITIAL_OUTPUT\r
++\r
++test_begin_subtest "output of count matches test code"\r
++notmuch count --output=modifications '*' > OUTPUT\r
++test_expect_equal_file INITIAL_OUTPUT OUTPUT\r
++\r
++test_begin_subtest "modification count increases"\r
++before=$(notmuch count --output=modifications '*' | cut -f2)\r
++notmuch tag +a-random-tag-8743632 '*'\r
++after=$(notmuch count --output=modifications '*' | cut -f2)\r
++result=$(($before < $after))\r
++test_expect_equal 1 ${result}\r
+ test_done\r
+-- \r
+2.1.4\r
+\r