Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 25 / 830fb6af80cd29e93085799c18059741d018d2
1 Return-Path: <bremner@tesseract.cs.unb.ca>\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 arlo.cworth.org (Postfix) with ESMTP id 4C0DF6DE17E8\r
6  for <notmuch@notmuchmail.org>; Fri,  5 Jun 2015 10:31:27 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.236\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.236 tagged_above=-999 required=5 tests=[AWL=0.226, \r
12  T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id hUTH_VJ9YrIY for <notmuch@notmuchmail.org>;\r
16  Fri,  5 Jun 2015 10:31:25 -0700 (PDT)\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
18  [87.98.215.224])\r
19  by arlo.cworth.org (Postfix) with ESMTPS id 632A56DE179F\r
20  for <notmuch@notmuchmail.org>; Fri,  5 Jun 2015 10:31:15 -0700 (PDT)\r
21 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
22  4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
23  id 1Z0vRx-0002oA-F6; Fri, 05 Jun 2015 17:30:33 +0000\r
24 Received: (nullmailer pid 24254 invoked by uid 1000); Fri, 05 Jun 2015\r
25  17:28:42 -0000\r
26 From: David Bremner <david@tethera.net>\r
27 To: notmuch@notmuchmail.org\r
28 Subject: [PATCH 4/6] cli/count: add --output=modifications\r
29 Date: Fri,  5 Jun 2015 19:28:36 +0200\r
30 Message-Id: <1433525318-23756-5-git-send-email-david@tethera.net>\r
31 X-Mailer: git-send-email 2.1.4\r
32 In-Reply-To: <1433525318-23756-1-git-send-email-david@tethera.net>\r
33 References: <1432936375-astroid-4-0i1n6yczs2-1520@strange>\r
34  <1433525318-23756-1-git-send-email-david@tethera.net>\r
35 X-BeenThere: notmuch@notmuchmail.org\r
36 X-Mailman-Version: 2.1.18\r
37 Precedence: list\r
38 List-Id: "Use and development of the notmuch mail system."\r
39  <notmuch.notmuchmail.org>\r
40 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
41  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
43 List-Post: <mailto:notmuch@notmuchmail.org>\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
45 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
46  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
47 X-List-Received-Date: Fri, 05 Jun 2015 17:31:27 -0000\r
48 \r
49 We need some way to extract the uuid/revision of the database, and\r
50 count seems like the least bad choice of current commands.\r
51 The (perhaps weak) argument for count over search is that count\r
52 already reports statistics about the entire database.\r
53 ---\r
54  notmuch-count.c                | 18 +++++++++++++++++-\r
55  test/T570-revision-tracking.sh | 12 ++++++++++++\r
56  2 files changed, 29 insertions(+), 1 deletion(-)\r
57 \r
58 diff --git a/notmuch-count.c b/notmuch-count.c\r
59 index 57a88a8..7c61ccb 100644\r
60 --- a/notmuch-count.c\r
61 +++ b/notmuch-count.c\r
62 @@ -25,6 +25,7 @@ enum {\r
63      OUTPUT_THREADS,\r
64      OUTPUT_MESSAGES,\r
65      OUTPUT_FILES,\r
66 +    OUTPUT_LASTMOD,\r
67  };\r
68  \r
69  /* The following is to allow future options to be added more easily */\r
70 @@ -71,6 +72,9 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
71  {\r
72      notmuch_query_t *query;\r
73      size_t i;\r
74 +    unsigned long revision;\r
75 +    const char *uuid;\r
76 +    int ret = 0;\r
77  \r
78      query = notmuch_query_create (notmuch, query_str);\r
79      if (query == NULL) {\r
80 @@ -91,11 +95,22 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
81      case OUTPUT_FILES:\r
82         printf ("%u\n", count_files (query));\r
83         break;\r
84 +    case OUTPUT_LASTMOD:\r
85 +       if (strcmp (notmuch_query_get_query_string (query), "*") != 0) {\r
86 +           fprintf (stderr, "Error: Only '*' is currently supported "\r
87 +                    " with output=modifications\n");\r
88 +           ret = 1;\r
89 +           goto DONE;\r
90 +       }\r
91 +\r
92 +       revision = notmuch_database_get_revision (notmuch, &uuid);\r
93 +       printf ("%s\t%lu\n", uuid, revision);\r
94      }\r
95  \r
96 + DONE:\r
97      notmuch_query_destroy (query);\r
98  \r
99 -    return 0;\r
100 +    return ret;\r
101  }\r
102  \r
103  static int\r
104 @@ -139,6 +154,7 @@ notmuch_count_command (notmuch_config_t *config, int argc, char *argv[])\r
105           (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS },\r
106                                   { "messages", OUTPUT_MESSAGES },\r
107                                   { "files", OUTPUT_FILES },\r
108 +                                 { "modifications", OUTPUT_LASTMOD },\r
109                                   { 0, 0 } } },\r
110         { NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x',\r
111           (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },\r
112 diff --git a/test/T570-revision-tracking.sh b/test/T570-revision-tracking.sh\r
113 index 74a7c49..062fd59 100755\r
114 --- a/test/T570-revision-tracking.sh\r
115 +++ b/test/T570-revision-tracking.sh\r
116 @@ -34,4 +34,16 @@ UUID 53\r
117  EOF\r
118  test_expect_equal_file EXPECTED CLEAN\r
119  \r
120 +grep '^[0-9a-f]' OUTPUT > INITIAL_OUTPUT\r
121 +\r
122 +test_begin_subtest "output of count matches test code"\r
123 +notmuch count --output=modifications '*' > OUTPUT\r
124 +test_expect_equal_file INITIAL_OUTPUT OUTPUT\r
125 +\r
126 +test_begin_subtest "modification count increases"\r
127 +before=$(notmuch count --output=modifications '*' | cut -f2)\r
128 +notmuch tag +a-random-tag-8743632 '*'\r
129 +after=$(notmuch count --output=modifications '*' | cut -f2)\r
130 +result=$(($before < $after))\r
131 +test_expect_equal 1 ${result}\r
132  test_done\r
133 -- \r
134 2.1.4\r
135 \r