database error
[notmuch-archives.git] / 69 / 624f17d64dc48575a2e238540f96065c0dd350
1 Return-Path: <keithp@keithp.com>\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 A3F0C431FBF\r
6         for <notmuch@notmuchmail.org>; Wed, 18 Nov 2009 13:46:04 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id Na4UJR2xWfHB for <notmuch@notmuchmail.org>;\r
11         Wed, 18 Nov 2009 13:46:03 -0800 (PST)\r
12 Received: from keithp.com (home.keithp.com [63.227.221.253])\r
13         by olra.theworths.org (Postfix) with ESMTP id 90B99431FBC\r
14         for <notmuch@notmuchmail.org>; Wed, 18 Nov 2009 13:46:03 -0800 (PST)\r
15 Received: from localhost (localhost [127.0.0.1])\r
16         by keithp.com (Postfix) with ESMTP id 0665EB9404C\r
17         for <notmuch@notmuchmail.org>; Wed, 18 Nov 2009 13:46:03 -0800 (PST)\r
18 X-Virus-Scanned: Debian amavisd-new at keithp.com\r
19 Received: from keithp.com ([127.0.0.1])\r
20         by localhost (keithp.com [127.0.0.1]) (amavisd-new, port 10024)\r
21         with LMTP id PNyzIBrT-lJf; Wed, 18 Nov 2009 13:46:00 -0800 (PST)\r
22 Received: by keithp.com (Postfix, from userid 1033)\r
23         id 1609BB9402F; Wed, 18 Nov 2009 13:46:00 -0800 (PST)\r
24 Received: from koto.keithp.com (localhost [127.0.0.1])\r
25         by keithp.com (Postfix) with ESMTP id 13B6EB88003;\r
26         Wed, 18 Nov 2009 13:46:00 -0800 (PST)\r
27 Received: by koto.keithp.com (Postfix, from userid 1488)\r
28         id B11841581A5; Wed, 18 Nov 2009 13:45:59 -0800 (PST)\r
29 From: Keith Packard <keithp@keithp.com>\r
30 To: notmuch@notmuchmail.org\r
31 Date: Wed, 18 Nov 2009 13:45:58 -0800\r
32 Message-Id: <1258580758-24474-1-git-send-email-keithp@keithp.com>\r
33 X-Mailer: git-send-email 1.6.5.2\r
34 Subject: [notmuch] [PATCH] Make reply/show/tag all require at least one\r
35         search term\r
36 X-BeenThere: notmuch@notmuchmail.org\r
37 X-Mailman-Version: 2.1.12\r
38 Precedence: list\r
39 List-Id: "Use and development of the notmuch mail system."\r
40         <notmuch.notmuchmail.org>\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
42         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
44 List-Post: <mailto:notmuch@notmuchmail.org>\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
48 X-List-Received-Date: Wed, 18 Nov 2009 21:46:04 -0000\r
49 \r
50 In particular, notmuch tag -inbox "" tended to take a long time to\r
51 run, happened if you hit 'a' on a blank line in the search view and\r
52 probably didn't have the desired effect.\r
53 \r
54 Signed-off-by: Keith Packard <keithp@keithp.com>\r
55 ---\r
56  notmuch-reply.c |   13 +++++++++----\r
57  notmuch-show.c  |   13 +++++++++----\r
58  notmuch-tag.c   |    8 ++++----\r
59  3 files changed, 22 insertions(+), 12 deletions(-)\r
60 \r
61 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
62 index 4a4a782..31e2c87 100644\r
63 --- a/notmuch-reply.c\r
64 +++ b/notmuch-reply.c\r
65 @@ -196,16 +196,21 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
66      if (config == NULL)\r
67         return 1;\r
68  \r
69 -    notmuch = notmuch_database_open (notmuch_config_get_database_path (config));\r
70 -    if (notmuch == NULL)\r
71 -       return 1;\r
72 -\r
73      query_string = query_string_from_args (ctx, argc, argv);\r
74      if (query_string == NULL) {\r
75         fprintf (stderr, "Out of memory\n");\r
76         return 1;\r
77      }\r
78  \r
79 +    if (*query_string == '\0') {\r
80 +       fprintf (stderr, "Error: notmuch reply requires at least one search term.\n");\r
81 +       return 1;\r
82 +    }\r
83 +\r
84 +    notmuch = notmuch_database_open (notmuch_config_get_database_path (config));\r
85 +    if (notmuch == NULL)\r
86 +       return 1;\r
87 +\r
88      query = notmuch_query_create (notmuch, query_string);\r
89      if (query == NULL) {\r
90         fprintf (stderr, "Out of memory\n");\r
91 diff --git a/notmuch-show.c b/notmuch-show.c\r
92 index 59a58c2..c0c3ca3 100644\r
93 --- a/notmuch-show.c\r
94 +++ b/notmuch-show.c\r
95 @@ -196,16 +196,21 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
96      if (config == NULL)\r
97         return 1;\r
98  \r
99 -    notmuch = notmuch_database_open (notmuch_config_get_database_path (config));\r
100 -    if (notmuch == NULL)\r
101 -       return 1;\r
102 -\r
103      query_string = query_string_from_args (ctx, argc, argv);\r
104      if (query_string == NULL) {\r
105         fprintf (stderr, "Out of memory\n");\r
106         return 1;\r
107      }\r
108  \r
109 +    if (*query_string == '\0') {\r
110 +       fprintf (stderr, "Error: notmuch show requires at least one search term.\n");\r
111 +       return 1;\r
112 +    }\r
113 +\r
114 +    notmuch = notmuch_database_open (notmuch_config_get_database_path (config));\r
115 +    if (notmuch == NULL)\r
116 +       return 1;\r
117 +\r
118      query = notmuch_query_create (notmuch, query_string);\r
119      if (query == NULL) {\r
120         fprintf (stderr, "Out of memory\n");\r
121 diff --git a/notmuch-tag.c b/notmuch-tag.c\r
122 index 7d92ec4..12ab86c 100644\r
123 --- a/notmuch-tag.c\r
124 +++ b/notmuch-tag.c\r
125 @@ -83,8 +83,10 @@ notmuch_tag_command (void *ctx, unused (int argc), unused (char *argv[]))\r
126         return 1;\r
127      }\r
128  \r
129 -    if (i == argc) {\r
130 -       fprintf (stderr, "Error: 'notmuch tag' requires at least one search term.\n");\r
131 +    query_string = query_string_from_args (ctx, argc - i, &argv[i]);\r
132 +\r
133 +    if (*query_string == '\0') {\r
134 +       fprintf (stderr, "Error: notmuch tag requires at least one search term.\n");\r
135         return 1;\r
136      }\r
137  \r
138 @@ -96,8 +98,6 @@ notmuch_tag_command (void *ctx, unused (int argc), unused (char *argv[]))\r
139      if (notmuch == NULL)\r
140         return 1;\r
141  \r
142 -    query_string = query_string_from_args (ctx, argc - i, &argv[i]);\r
143 -\r
144      query = notmuch_query_create (notmuch, query_string);\r
145      if (query == NULL) {\r
146         fprintf (stderr, "Out of memory.\n");\r
147 -- \r
148 1.6.5.2\r
149 \r