--- /dev/null
+Return-Path: <amdragon@mit.edu>\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 1B0F4431FC7\r
+ for <notmuch@notmuchmail.org>; Sat, 1 Dec 2012 18:40:14 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 RoMxAGyO8i8r for <notmuch@notmuchmail.org>;\r
+ Sat, 1 Dec 2012 18:40:13 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU\r
+ [18.7.68.36])\r
+ by olra.theworths.org (Postfix) with ESMTP id 410F3431FAF\r
+ for <notmuch@notmuchmail.org>; Sat, 1 Dec 2012 18:40:13 -0800 (PST)\r
+X-AuditID: 12074424-b7fe06d0000008f0-32-50babf8cc353\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+ by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 68.06.02288.C8FBAB05; Sat, 1 Dec 2012 21:40:12 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id qB22eCqo013712; \r
+ Sat, 1 Dec 2012 21:40:12 -0500\r
+Received: from drake.dyndns.org\r
+ (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+ [209.6.116.242]) (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qB22e6pS025595\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Sat, 1 Dec 2012 21:40:10 -0500 (EST)\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1TezTR-0000xT-R5; Sat, 01 Dec 2012 21:40:05 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 02/10] search: Support --use-schema\r
+Date: Sat, 1 Dec 2012 21:39:54 -0500\r
+Message-Id: <1354416002-3557-2-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1354416002-3557-1-git-send-email-amdragon@mit.edu>\r
+References: <1354416002-3557-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFlrHIsWRmVeSWpSXmKPExsUixCmqrNuzf1eAQfNdeYvrN2cyOzB6PFt1\r
+ izmAMYrLJiU1J7MstUjfLoErY+7GgoKVIhXn525jbmBcItDFyMEhIWAiceyNexcjJ5ApJnHh\r
+ 3nq2LkYuDiGBfYwS57vfMEE46xklDux+BpV5yCRx5uQ/ZghnLqPE0kN7mED62QQ0JLbtX84I\r
+ YosISEvsvDubFWQFs4CaxJ8uFRBTWMBY4vLrRBCTRUBVov+/Dkgxr4C9xOl9zWwQRyhKdD+b\r
+ wAZSwingILGimwckLARU8v/3NbYJjPwLGBlWMcqm5Fbp5iZm5hSnJusWJyfm5aUW6Zrr5WaW\r
+ 6KWmlG5iBAULu4vKDsbmQ0qHGAU4GJV4eCPn7AoQYk0sK67MPcQoycGkJMp7ZQdQiC8pP6Uy\r
+ I7E4I76oNCe1+BCjBAezkggviwlQjjclsbIqtSgfJiXNwaIkzns95aa/kEB6YklqdmpqQWoR\r
+ TFaGg0NJgvfyXqBGwaLU9NSKtMycEoQ0EwcnyHAeoOEZIDW8xQWJucWZ6RD5U4yKUuK8USAJ\r
+ AZBERmkeXC8sml8xigO9IswrsA+oigeYCOC6XwENZgIa/GbZdpDBJYkIKakGRpm317ZFTlp9\r
+ cU/t/0f9LYmmvjKl/sqvuSyqbT2v3OAK+aemd3R6cPlhQ8XlJx3nXwk0d/zctr7npWCjQoLt\r
+ 5Yu1kVPqOxb++Jfzvf7ssqwj7bl6X33TKjJ/7b5lcsH5xeeyeN+PP6aLyPY4O4bkKp7MNdtg\r
+ YmMpo6qfrvR5mchRb/XAmN3PlFiKMxINtZiLihMBYmPGYcECAAA=\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, 02 Dec 2012 02:40:14 -0000\r
+\r
+---\r
+ man/man1/notmuch-search.1 | 20 ++++++++++++++++++++\r
+ notmuch-client.h | 2 ++\r
+ notmuch-search.c | 3 +++\r
+ 3 files changed, 25 insertions(+)\r
+\r
+diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1\r
+index 6ccd3b8..79dc1fe 100644\r
+--- a/man/man1/notmuch-search.1\r
++++ b/man/man1/notmuch-search.1\r
+@@ -32,6 +32,15 @@ Presents the results in either JSON or plain-text (default).\r
+ \r
+ .RS 4\r
+ .TP 4\r
++.BR \-\-use-schema=N\r
++\r
++Use the specified structured output schema version. This is intended\r
++for programs that invoke \fBnotmuch\fR(1) internally. If omitted, the\r
++latest supported version will be used.\r
++.RE\r
++\r
++.RS 4\r
++.TP 4\r
+ .B \-\-output=(summary|threads|messages|files|tags)\r
+ \r
+ .RS 4\r
+@@ -125,6 +134,17 @@ In this case all matching threads are returned but the "match count"\r
+ is the number of matching non-excluded messages in the thread.\r
+ .RE\r
+ \r
++.SH EXIT STATUS\r
++\r
++This command supports the following special exit status codes\r
++\r
++.TP\r
++.B 20\r
++The requested schema version is too old.\r
++.TP\r
++.B 21\r
++The requested schema version is too new.\r
++\r
+ .SH SEE ALSO\r
+ \r
+ \fBnotmuch\fR(1), \fBnotmuch-config\fR(1), \fBnotmuch-count\fR(1),\r
+diff --git a/notmuch-client.h b/notmuch-client.h\r
+index 14e7363..95c4dd7 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -140,6 +140,8 @@ chomp_newline (char *str)\r
+ * "current" version is consistent across all parts of the schema.\r
+ */\r
+ #define NOTMUCH_SCHEMA_CUR 1\r
++/* The minimum schema version supported by the "search" command. */\r
++#define NOTMUCH_SCHEMA_SEARCH 1\r
+ \r
+ /* The schema version requested by the caller on the command line. If\r
+ * no schema version is requested, this should be set to\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 830c4e4..477f9eb 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -317,6 +317,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
+ (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },\r
+ { "text", NOTMUCH_FORMAT_TEXT },\r
+ { 0, 0 } } },\r
++ { NOTMUCH_OPT_INT, ¬much_schema_version, "use-schema", 0, 0 },\r
+ { NOTMUCH_OPT_KEYWORD, &output, "output", 'o',\r
+ (notmuch_keyword_t []){ { "summary", OUTPUT_SUMMARY },\r
+ { "threads", OUTPUT_THREADS },\r
+@@ -352,6 +353,8 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
+ INTERNAL_ERROR("no output format selected");\r
+ }\r
+ \r
++ notmuch_exit_if_unsupported_schema ("search", NOTMUCH_SCHEMA_SEARCH);\r
++\r
+ config = notmuch_config_open (ctx, NULL, NULL);\r
+ if (config == NULL)\r
+ return 1;\r
+-- \r
+1.7.10.4\r
+\r