[Patch v3 3/4] cli: update to use new count API
authorDavid Bremner <david@tethera.net>
Sun, 27 Sep 2015 02:50:12 +0000 (23:50 +2100)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:49:39 +0000 (14:49 -0700)
d4/b3bb1b2a8301fc4236c8894597f9db1c28bb41 [new file with mode: 0644]

diff --git a/d4/b3bb1b2a8301fc4236c8894597f9db1c28bb41 b/d4/b3bb1b2a8301fc4236c8894597f9db1c28bb41
new file mode 100644 (file)
index 0000000..592457a
--- /dev/null
@@ -0,0 +1,166 @@
+Return-Path: <bremner@tethera.net>\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 91BBB6DE176C\r
+ for <notmuch@notmuchmail.org>; Sat, 26 Sep 2015 19:51:49 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.112\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.112 tagged_above=-999 required=5 tests=[AWL=0.112]\r
+ 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 P2ATvmFSVMNT for <notmuch@notmuchmail.org>;\r
+ Sat, 26 Sep 2015 19:51:48 -0700 (PDT)\r
+Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id C992D6DE176A\r
+ for <notmuch@notmuchmail.org>; Sat, 26 Sep 2015 19:51:47 -0700 (PDT)\r
+Received: from remotemail by gitolite.debian.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1Zg23N-0005bO-2n; Sun, 27 Sep 2015 02:51:05 +0000\r
+Received: (nullmailer pid 31137 invoked by uid 1000); Sun, 27 Sep 2015\r
+ 02:50:26 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v3 3/4] cli: update to use new count API\r
+Date: Sat, 26 Sep 2015 23:50:12 -0300\r
+Message-Id: <1443322213-31075-4-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.5.3\r
+In-Reply-To: <1443322213-31075-1-git-send-email-david@tethera.net>\r
+References: <1443322213-31075-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, 27 Sep 2015 02:51:49 -0000\r
+\r
+Essentially replace each call to notmuch_count_* with the corresponding\r
+_st call, followed by print_status_query.\r
+---\r
+ notmuch-count.c  | 12 ++++++++++--\r
+ notmuch-reply.c  |  7 ++++++-\r
+ notmuch-search.c | 16 ++++++++++++++--\r
+ notmuch-show.c   |  7 ++++++-\r
+ 4 files changed, 36 insertions(+), 6 deletions(-)\r
+\r
+diff --git a/notmuch-count.c b/notmuch-count.c\r
+index be3e236..0b6e6f5 100644\r
+--- a/notmuch-count.c\r
++++ b/notmuch-count.c\r
+@@ -75,9 +75,11 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
+     notmuch_query_t *query;\r
+     size_t i;\r
+     int count;\r
++    unsigned int ucount;\r
+     unsigned long revision;\r
+     const char *uuid;\r
+     int ret = 0;\r
++    notmuch_status_t status;\r
\r
+     query = notmuch_query_create (notmuch, query_str);\r
+     if (query == NULL) {\r
+@@ -90,10 +92,16 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
\r
+     switch (output) {\r
+     case OUTPUT_MESSAGES:\r
+-      printf ("%u", notmuch_query_count_messages (query));\r
++      status = notmuch_query_count_messages_st (query, &ucount);\r
++      if (print_status_query ("notmuch count", query, status))\r
++          return -1;\r
++      printf ("%u", ucount);\r
+       break;\r
+     case OUTPUT_THREADS:\r
+-      printf ("%u", notmuch_query_count_threads (query));\r
++      status = notmuch_query_count_threads_st (query, &ucount);\r
++      if (print_status_query ("notmuch count", query, status))\r
++          return -1;\r
++      printf ("%u", ucount);\r
+       break;\r
+     case OUTPUT_FILES:\r
+       count = count_files (query);\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index fd6a1ec..1357142 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -655,9 +655,14 @@ notmuch_reply_format_sprinter(void *ctx,\r
+     notmuch_messages_t *messages;\r
+     notmuch_message_t *message;\r
+     mime_node_t *node;\r
++    unsigned count;\r
+     notmuch_status_t status;\r
\r
+-    if (notmuch_query_count_messages (query) != 1) {\r
++    status = notmuch_query_count_messages_st (query, &count);\r
++    if (print_status_query ("notmuch reply", query, status))\r
++      return 1;\r
++\r
++    if (count != 1) {\r
+       fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
+       return 1;\r
+     }\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 44e582c..56895e0 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -121,7 +121,13 @@ do_search_threads (search_context_t *ctx)\r
+     notmuch_status_t status;\r
\r
+     if (ctx->offset < 0) {\r
+-      ctx->offset += notmuch_query_count_threads (ctx->query);\r
++      unsigned count;\r
++      notmuch_status_t status;\r
++      status = notmuch_query_count_threads_st (ctx->query, &count);\r
++      if (print_status_query ("notmuch search", ctx->query, status)\r
++          return 1;\r
++\r
++      ctx->offset += count;\r
+       if (ctx->offset < 0)\r
+           ctx->offset = 0;\r
+     }\r
+@@ -521,7 +527,13 @@ do_search_messages (search_context_t *ctx)\r
+     notmuch_status_t status;\r
\r
+     if (ctx->offset < 0) {\r
+-      ctx->offset += notmuch_query_count_messages (ctx->query);\r
++      unsigned count;\r
++      notmuch_status_t status;\r
++      status = notmuch_query_count_messages_st (ctx->query, &count);\r
++      if (print_status_query ("notmuch search", ctx->query, status)\r
++          return 1;\r
++\r
++      ctx->offset += count;\r
+       if (ctx->offset < 0)\r
+           ctx->offset = 0;\r
+     }\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index e054808..5a83c60 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -896,8 +896,13 @@ do_show_single (void *ctx,\r
+     notmuch_messages_t *messages;\r
+     notmuch_message_t *message;\r
+     notmuch_status_t status;\r
++    unsigned int count;\r
\r
+-    if (notmuch_query_count_messages (query) != 1) {\r
++    status = notmuch_query_count_messages_st (query, &count);\r
++    if (print_status_query ("notmuch show", query, status))\r
++      return 1;\r
++\r
++    if (count != 1) {\r
+       fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
+       return 1;\r
+     }\r
+-- \r
+2.5.3\r
+\r