Re: notmuch-tree display
[notmuch-archives.git] / 8e / cd7b927f20161d1c56c61e560f807def234ddd
1 Return-Path: <novalazy@gmail.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 74824431FD6\r
6         for <notmuch@notmuchmail.org>; Thu, 24 Jan 2013 04:09:26 -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: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 lSVwp4Wmo950 for <notmuch@notmuchmail.org>;\r
17         Thu, 24 Jan 2013 04:09:25 -0800 (PST)\r
18 Received: from mail-da0-f54.google.com (mail-da0-f54.google.com\r
19         [209.85.210.54]) (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 63318431FCF\r
22         for <notmuch@notmuchmail.org>; Thu, 24 Jan 2013 04:09:20 -0800 (PST)\r
23 Received: by mail-da0-f54.google.com with SMTP id n2so4258646dad.41\r
24         for <notmuch@notmuchmail.org>; Thu, 24 Jan 2013 04:09:19 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26         h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
27         :references; bh=VP7cZ2RmGU8gvZ3Iw4FhGlvKPM5YnlMkTxsxbZt0fQo=;\r
28         b=sfA0Yuvf0qiH7JLtAAnjL1faOZaTKVxSWg+01HRaJ6aszRet7hgKEOg3eELhYzHLtl\r
29         wLO3a+I9AA5HPaJ4rBzsWE3SUYQRX7XczL6EchO2y95EkTLME9ZcfB0Dp0dUwX/WIGgz\r
30         sDU9WkuF3RFMf3ULY7dQsOPjlclTpqQJoJbQEmR+RBhH2KVd0YDR62jMzqEuTHEYvKRC\r
31         H3dppbVoTnDOps5xnDQ/OWDJilHcorxjjyJCqYim+6ctsbQ/W84PO3bR0aLR473BA0TR\r
32         8R7kOSGTpFejVfboij418pakOledYn2qhYdgKJSFOi7/GhyutD1LOs9q0rAXpR4v75Ci\r
33         1TpQ==\r
34 X-Received: by 10.68.220.6 with SMTP id ps6mr4191667pbc.80.1359029359643;\r
35         Thu, 24 Jan 2013 04:09:19 -0800 (PST)\r
36 Received: from localhost (215.42.233.220.static.exetel.com.au.\r
37         [220.233.42.215])\r
38         by mx.google.com with ESMTPS id o6sm15590382paw.37.2013.01.24.04.09.17\r
39         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
40         Thu, 24 Jan 2013 04:09:18 -0800 (PST)\r
41 From: Peter Wang <novalazy@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v4 01/12] tag-util: move out 'tag' command-line checks\r
44 Date: Thu, 24 Jan 2013 23:07:57 +1100\r
45 Message-Id: <1359029288-12132-2-git-send-email-novalazy@gmail.com>\r
46 X-Mailer: git-send-email 1.7.12.1\r
47 In-Reply-To: <1359029288-12132-1-git-send-email-novalazy@gmail.com>\r
48 References: <1359029288-12132-1-git-send-email-novalazy@gmail.com>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Thu, 24 Jan 2013 12:09:26 -0000\r
62 \r
63 parse_tag_command_line checked for two error conditions which are\r
64 specific to the 'tag' command.  It can be reused for the forthcoming\r
65 notmuch 'insert' command if we move the checks out, into notmuch-tag.c.\r
66 ---\r
67  notmuch-tag.c | 10 ++++++++++\r
68  tag-util.c    | 11 +++--------\r
69  2 files changed, 13 insertions(+), 8 deletions(-)\r
70 \r
71 diff --git a/notmuch-tag.c b/notmuch-tag.c\r
72 index d9daf8f..a901dad 100644\r
73 --- a/notmuch-tag.c\r
74 +++ b/notmuch-tag.c\r
75 @@ -234,6 +234,16 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])\r
76         if (parse_tag_command_line (ctx, argc - opt_index, argv + opt_index,\r
77                                     &query_string, tag_ops))\r
78             return 1;\r
79 +\r
80 +       if (tag_op_list_size (tag_ops) == 0) {\r
81 +           fprintf (stderr, "Error: 'notmuch tag' requires at least one tag to add or remove.\n");\r
82 +           return 1;\r
83 +       }\r
84 +\r
85 +       if (*query_string == '\0') {\r
86 +           fprintf (stderr, "Error: notmuch tag requires at least one search term.\n");\r
87 +           return 1;\r
88 +       }\r
89      }\r
90  \r
91      config = notmuch_config_open (ctx, NULL, NULL);\r
92 diff --git a/tag-util.c b/tag-util.c\r
93 index 701d329..743d591 100644\r
94 --- a/tag-util.c\r
95 +++ b/tag-util.c\r
96 @@ -188,16 +188,11 @@ parse_tag_command_line (void *ctx, int argc, char **argv,\r
97         tag_op_list_append (tag_ops, argv[i] + 1, is_remove);\r
98      }\r
99  \r
100 -    if (tag_op_list_size (tag_ops) == 0) {\r
101 -       fprintf (stderr, "Error: 'notmuch tag' requires at least one tag to add or remove.\n");\r
102 -       return TAG_PARSE_INVALID;\r
103 -    }\r
104 -\r
105      *query_str = query_string_from_args (ctx, argc - i, &argv[i]);\r
106  \r
107 -    if (*query_str == NULL || **query_str == '\0') {\r
108 -       fprintf (stderr, "Error: notmuch tag requires at least one search term.\n");\r
109 -       return TAG_PARSE_INVALID;\r
110 +    if (*query_str == NULL) {\r
111 +       fprintf (stderr, "Out of memory.\n");\r
112 +       return TAG_PARSE_OUT_OF_MEMORY;\r
113      }\r
114  \r
115      return TAG_PARSE_SUCCESS;\r
116 -- \r
117 1.7.12.1\r
118 \r