--- /dev/null
+Return-Path: <novalazy@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 7309D431FAE\r
+ for <notmuch@notmuchmail.org>; Sat, 22 Jun 2013 21:24:08 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.099\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.099 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id rtW5lIGrtrea for <notmuch@notmuchmail.org>;\r
+ Sat, 22 Jun 2013 21:24:00 -0700 (PDT)\r
+Received: from mail-pd0-f171.google.com (mail-pd0-f171.google.com\r
+ [209.85.192.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id BAA1A431FB6\r
+ for <notmuch@notmuchmail.org>; Sat, 22 Jun 2013 21:24:00 -0700 (PDT)\r
+Received: by mail-pd0-f171.google.com with SMTP id y14so195434pdi.16\r
+ for <notmuch@notmuchmail.org>; Sat, 22 Jun 2013 21:24:00 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+ bh=66Vd2nPB29AX4mZnRZ1lIeg1mcEHnjPgcEBgNCewqx0=;\r
+ b=BKInLUn/2ZH6x0flHvrF8XTXzIPO+jntxNyuON7DqIHErtUogwkC6XoEXmS8YdRTor\r
+ J3wmXASDZ+G/SG0XM+WpLJxaHgdLBerqiRnjmnwrJf9UOQc0uyLGx/5nHcg2IfomNbFW\r
+ 7yTP5Ck+TjspKNmlV/2yyzP48pCD0PykhoYjn7ToP3lVziDNxgoHuY7h3dLiEmLmGUXO\r
+ vsKeS5YadtIhapfp9th5BjU699kvMrCMF8ETVxkcHa086MhhCwzsOwmaKFKgDP2/4GOU\r
+ s3xhIRRJn/WWujaz/bMovViqGtV8iC25aWRgFBOvzgwcHPlejhL0I4Y0S4b+3YvXUvKY\r
+ OG3w==\r
+X-Received: by 10.66.150.168 with SMTP id uj8mr22586746pab.34.1371961440010;\r
+ Sat, 22 Jun 2013 21:24:00 -0700 (PDT)\r
+Received: from localhost (215.42.233.220.static.exetel.com.au.\r
+ [220.233.42.215]) by mx.google.com with ESMTPSA id\r
+ z19sm13166783paf.12.2013.06.22.21.23.57 for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sat, 22 Jun 2013 21:23:59 -0700 (PDT)\r
+From: Peter Wang <novalazy@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v7 01/12] tag-util: move out 'tag' command-line check\r
+Date: Sun, 23 Jun 2013 14:23:54 +1000\r
+Message-Id: <1371961445-15182-2-git-send-email-novalazy@gmail.com>\r
+X-Mailer: git-send-email 1.7.12.1\r
+In-Reply-To: <1371961445-15182-1-git-send-email-novalazy@gmail.com>\r
+References: <1371961445-15182-1-git-send-email-novalazy@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\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, 23 Jun 2013 04:24:08 -0000\r
+\r
+Move an error condition specific to the 'tag' command out of\r
+parse_tag_command_line so that parse_tag_command_line can be used for\r
+the forthcoming 'insert' command.\r
+---\r
+ notmuch-tag.c | 5 +++++\r
+ tag-util.c | 6 +++---\r
+ 2 files changed, 8 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/notmuch-tag.c b/notmuch-tag.c\r
+index 9a5d3e7..3b09df9 100644\r
+--- a/notmuch-tag.c\r
++++ b/notmuch-tag.c\r
+@@ -247,6 +247,11 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[])\r
+ fprintf (stderr, "Error: 'notmuch tag' requires at least one tag to add or remove.\n");\r
+ return 1;\r
+ }\r
++\r
++ if (*query_string == '\0') {\r
++ fprintf (stderr, "Error: notmuch tag requires at least one search term.\n");\r
++ return 1;\r
++ }\r
+ }\r
+ \r
+ if (notmuch_database_open (notmuch_config_get_database_path (config),\r
+diff --git a/tag-util.c b/tag-util.c\r
+index c5f5859..92e08a1 100644\r
+--- a/tag-util.c\r
++++ b/tag-util.c\r
+@@ -190,9 +190,9 @@ parse_tag_command_line (void *ctx, int argc, char **argv,\r
+ \r
+ *query_str = query_string_from_args (ctx, argc - i, &argv[i]);\r
+ \r
+- if (*query_str == NULL || **query_str == '\0') {\r
+- fprintf (stderr, "Error: notmuch tag requires at least one search term.\n");\r
+- return TAG_PARSE_INVALID;\r
++ if (*query_str == NULL) {\r
++ fprintf (stderr, "Out of memory.\n");\r
++ return TAG_PARSE_OUT_OF_MEMORY;\r
+ }\r
+ \r
+ return TAG_PARSE_SUCCESS;\r
+-- \r
+1.7.12.1\r
+\r