--- /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 365976DE02D2\r
+ for <notmuch@notmuchmail.org>; Sun, 9 Aug 2015 02:26:29 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.141\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.141 tagged_above=-999 required=5 tests=[AWL=0.131, \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 LyMtrejHLb4g for <notmuch@notmuchmail.org>;\r
+ Sun, 9 Aug 2015 02:26:27 -0700 (PDT)\r
+Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 776F46DE100F\r
+ for <notmuch@notmuchmail.org>; Sun, 9 Aug 2015 02:26:27 -0700 (PDT)\r
+Received: from remotemail by gitolite.debian.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+ id 1ZOMrR-0005WJ-6e; Sun, 09 Aug 2015 09:25:45 +0000\r
+Received: (nullmailer pid 7065 invoked by uid 1000); Sun, 09 Aug 2015\r
+ 09:24:47 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/5] cli/count: add --output=modifications\r
+Date: Sun, 9 Aug 2015 11:24:43 +0200\r
+Message-Id: <1439112285-6681-4-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1439112285-6681-1-git-send-email-david@tethera.net>\r
+References: <1439112285-6681-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: Sun, 09 Aug 2015 09:26:29 -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 e0a5703..008c5d0 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