Re: [PATCH v4 16/16] add "notmuch reindex" subcommand
[notmuch-archives.git] / 3e / 9adfbd4f67d888eb56d7fe9fec19b505d0e151
1 Return-Path: <jani@nikula.org>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 21C0E431FBC\r
6         for <notmuch@notmuchmail.org>; Sat,  7 Mar 2015 06:00:38 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 1.738\r
10 X-Spam-Level: *\r
11 X-Spam-Status: No, score=1.738 tagged_above=-999 required=5\r
12         tests=[DNS_FROM_AHBL_RHSBL=2.438, RCVD_IN_DNSWL_LOW=-0.7]\r
13         autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id mnspBoGBoB+T for <notmuch@notmuchmail.org>;\r
17         Sat,  7 Mar 2015 06:00:35 -0800 (PST)\r
18 Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com\r
19         [209.85.212.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id B27C2431FAE\r
22         for <notmuch@notmuchmail.org>; Sat,  7 Mar 2015 06:00:34 -0800 (PST)\r
23 Received: by widex7 with SMTP id ex7so8954426wid.3\r
24         for <notmuch@notmuchmail.org>; Sat, 07 Mar 2015 06:00:33 -0800 (PST)\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=1e100.net; s=20130820;\r
27         h=x-gm-message-state:from:to:subject:in-reply-to:references\r
28         :user-agent:date:message-id:mime-version:content-type;\r
29         bh=YVV2JUurDzsr6lc7zVUKUmcXy/5h5FAab/nRvI9XA9M=;\r
30         b=GJ+NqAIjJKqcNee0QTgSHrarFF4KZdEe/Es7+P/qx/6EG0Rc5cvCYwMn5u7enST+mu\r
31         /aZxuqHcV4gTVFloeIci82jLLtTkJuK0uI0IyxryKOjVFHTcXSamToVrMBpl+lRxX3yf\r
32         cbJFVhuWy4qIP8TU7e28fn1ckNeqlTjEweGpPzb6MXHbVXobMVLrTKEeQ82KLwLecRJB\r
33         bKBNMC4F8XDLaV8271N4zjbdiT42PIJY2z2exyEyjjzYIRsqZ2IkX1HnHptdyPe6QTqC\r
34         wRQIeOhBfoJWsUT/5bDC2wsSd9jaKL7xQX8aftN4HCfqVCxPMofMbp4ibS0T5gSH4KYA\r
35         rNww==\r
36 X-Gm-Message-State:\r
37  ALoCoQnj/77iwdnWIVlmNOYH/FB8Q+dILdAT/Di6db9qPpimYww6sLkEmp+pAINzFbIRfHdbrCI6\r
38 X-Received: by 10.180.82.129 with SMTP id i1mr42296183wiy.77.1425736833854;\r
39         Sat, 07 Mar 2015 06:00:33 -0800 (PST)\r
40 Received: from localhost (mobile-internet-bcee3b-76.dhcp.inet.fi.\r
41         [188.238.59.76])\r
42         by mx.google.com with ESMTPSA id fa3sm6745204wib.17.2015.03.07.06.00.32\r
43         (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
44         Sat, 07 Mar 2015 06:00:33 -0800 (PST)\r
45 From: Jani Nikula <jani@nikula.org>\r
46 To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
47 Subject: Re: [PATCH 2/4] cli: update to use new count API\r
48 In-Reply-To: <1425717797-19990-3-git-send-email-david@tethera.net>\r
49 References: <1419971380-10307-6-git-send-email-david@tethera.net>\r
50         <1425717797-19990-1-git-send-email-david@tethera.net>\r
51         <1425717797-19990-3-git-send-email-david@tethera.net>\r
52 User-Agent: Notmuch/0.19+74~g6aeef2e (http://notmuchmail.org) Emacs/24.4.1\r
53         (x86_64-pc-linux-gnu)\r
54 Date: Sat, 07 Mar 2015 16:00:53 +0200\r
55 Message-ID: <87sidgj4a2.fsf@nikula.org>\r
56 MIME-Version: 1.0\r
57 Content-Type: text/plain\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Sat, 07 Mar 2015 14:00:38 -0000\r
71 \r
72 On Sat, 07 Mar 2015, David Bremner <david@tethera.net> wrote:\r
73 > Essentially replace each call to notmuch_count_* with an if block.\r
74 \r
75 LGTM, nitpicks inline.\r
76 \r
77 > ---\r
78 >  notmuch-count.c  | 14 ++++++++++++--\r
79 >  notmuch-reply.c  |  8 +++++++-\r
80 >  notmuch-search.c | 14 ++++++++++++--\r
81 >  notmuch-show.c   |  8 +++++++-\r
82 >  4 files changed, 38 insertions(+), 6 deletions(-)\r
83 >\r
84 > diff --git a/notmuch-count.c b/notmuch-count.c\r
85 > index 6058f7c..cd6b0c9 100644\r
86 > --- a/notmuch-count.c\r
87 > +++ b/notmuch-count.c\r
88 > @@ -71,6 +71,8 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
89 >  {\r
90 >      notmuch_query_t *query;\r
91 >      size_t i;\r
92 > +    unsigned count;\r
93 \r
94 As I said in patch 1, I'd personally prefer "unsigned int".\r
95 \r
96 > +    notmuch_status_t status;\r
97 >  \r
98 >      query = notmuch_query_create (notmuch, query_str);\r
99 >      if (query == NULL) {\r
100 > @@ -83,10 +85,18 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
101 >  \r
102 >      switch (output) {\r
103 >      case OUTPUT_MESSAGES:\r
104 > -     printf ("%u\n", notmuch_query_count_messages (query));\r
105 > +     if ((status = notmuch_query_count_messages_st (query, &count))) {\r
106 \r
107 I'd rather have the assignment and check in separate lines. Somehow I\r
108 feel it emphasizes the distinction between the happy day flow and the\r
109 unusual cases. Same for other hunks in this patch.\r
110 \r
111 > +         fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));\r
112 > +         return 1;\r
113 > +     }\r
114 > +     printf ("%u\n", count);\r
115 >       break;\r
116 >      case OUTPUT_THREADS:\r
117 > -     printf ("%u\n", notmuch_query_count_threads (query));\r
118 > +     if ((status = notmuch_query_count_threads_st (query, &count))) {\r
119 > +         fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));\r
120 > +         return 1;\r
121 > +     }\r
122 > +     printf ("%u\n", count);\r
123 >       break;\r
124 >      case OUTPUT_FILES:\r
125 >       printf ("%u\n", count_files (query));\r
126 > diff --git a/notmuch-reply.c b/notmuch-reply.c\r
127 > index 7c1c809..0b3e5fd 100644\r
128 > --- a/notmuch-reply.c\r
129 > +++ b/notmuch-reply.c\r
130 > @@ -650,8 +650,14 @@ notmuch_reply_format_sprinter(void *ctx,\r
131 >      notmuch_messages_t *messages;\r
132 >      notmuch_message_t *message;\r
133 >      mime_node_t *node;\r
134 > +    unsigned count;\r
135 > +    notmuch_status_t status;\r
136 >  \r
137 > -    if (notmuch_query_count_messages (query) != 1) {\r
138 > +    if ((status = notmuch_query_count_messages_st (query, &count))) {\r
139 > +     fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status));\r
140 > +     return 1;\r
141 > +    }\r
142 > +    if (count != 1) {\r
143 >       fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
144 >       return 1;\r
145 >      }\r
146 > diff --git a/notmuch-search.c b/notmuch-search.c\r
147 > index a591d45..ba631c0 100644\r
148 > --- a/notmuch-search.c\r
149 > +++ b/notmuch-search.c\r
150 > @@ -113,7 +113,14 @@ do_search_threads (search_context_t *ctx)\r
151 >      int i;\r
152 >  \r
153 >      if (ctx->offset < 0) {\r
154 > -     ctx->offset += notmuch_query_count_threads (ctx->query);\r
155 > +     unsigned count;\r
156 > +     notmuch_status_t status;\r
157 > +     if ((status = notmuch_query_count_threads_st (ctx->query, &count))) {\r
158 > +         fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));\r
159 > +         return 1;\r
160 > +     }\r
161 > +\r
162 > +     ctx->offset += count;\r
163 >       if (ctx->offset < 0)\r
164 >           ctx->offset = 0;\r
165 >      }\r
166 > @@ -414,7 +421,10 @@ do_search_messages (search_context_t *ctx)\r
167 >      int i;\r
168 >  \r
169 >      if (ctx->offset < 0) {\r
170 > -     ctx->offset += notmuch_query_count_messages (ctx->query);\r
171 > +     unsigned count;\r
172 > +     if (notmuch_query_count_messages_st (ctx->query, &count))\r
173 > +         return 1;\r
174 > +     ctx->offset += count;\r
175 >       if (ctx->offset < 0)\r
176 >           ctx->offset = 0;\r
177 >      }\r
178 > diff --git a/notmuch-show.c b/notmuch-show.c\r
179 > index d416fbd..749b1af 100644\r
180 > --- a/notmuch-show.c\r
181 > +++ b/notmuch-show.c\r
182 > @@ -982,8 +982,14 @@ do_show_single (void *ctx,\r
183 >  {\r
184 >      notmuch_messages_t *messages;\r
185 >      notmuch_message_t *message;\r
186 > +    unsigned count;\r
187 > +    notmuch_status_t status;\r
188 > +    if ((status = notmuch_query_count_messages_st (query, &count))) {\r
189 > +     fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));\r
190 > +     return 1;\r
191 > +    }\r
192 >  \r
193 > -    if (notmuch_query_count_messages (query) != 1) {\r
194 > +    if (count != 1) {\r
195 >       fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
196 >       return 1;\r
197 >      }\r
198 > -- \r
199 > 2.1.4\r
200 >\r
201 > _______________________________________________\r
202 > notmuch mailing list\r
203 > notmuch@notmuchmail.org\r
204 > http://notmuchmail.org/mailman/listinfo/notmuch\r