--- /dev/null
+Return-Path: <too@guru-group.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 3E7676DE0217\r
+ for <notmuch@notmuchmail.org>; Sat, 7 May 2016 12:24:29 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.265\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.265 tagged_above=-999 required=5 tests=[AWL=0.274, \r
+ HEADER_FROM_DIFFERENT_DOMAINS=0.001, T_RP_MATCHES_RCVD=-0.01]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id skPLeK_ClONd for <notmuch@notmuchmail.org>;\r
+ Sat, 7 May 2016 12:24:21 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 5DF3C6DE00EB\r
+ for <notmuch@notmuchmail.org>; Sat, 7 May 2016 12:24:21 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+ id 492F0100227; Sat, 7 May 2016 22:24:20 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Cc: tomi.ollila@iki.fi\r
+Subject: [PATCH] cli: tell how many messages were precisely matched when\r
+ expected 1 match\r
+Date: Sat, 7 May 2016 22:24:18 +0300\r
+Message-Id: <1462649058-5330-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 2.6.4\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 07 May 2016 19:24:29 -0000\r
+\r
+In case of notmuch reply and notmuch show --part=N it is required that\r
+search terms match to one message. If match count was != 1, error\r
+message "Error: search term did not match precisely one message"\r
+was too vague to explain what happened.\r
+\r
+By appending (matched <num> messages) to the error message it\r
+makes the problem more understandable (e.g when <num> is '0'\r
+user reckons the query had a typo in it).\r
+---\r
+ notmuch-reply.c | 2 +-\r
+ notmuch-show.c | 2 +-\r
+ test/T210-raw.sh | 2 +-\r
+ 3 files changed, 3 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index 3c6d685cbd60..a74194a31e4f 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -664,7 +664,7 @@ notmuch_reply_format_sprinter(void *ctx,\r
+ return 1;\r
+ \r
+ if (count != 1) {\r
+- fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
++ fprintf (stderr, "Error: search term did not match precisely one message (matched %d messages).\n", count);\r
+ return 1;\r
+ }\r
+ \r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index 87e52bbc0e81..3d5033d644b3 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -904,7 +904,7 @@ do_show_single (void *ctx,\r
+ return 1;\r
+ \r
+ if (count != 1) {\r
+- fprintf (stderr, "Error: search term did not match precisely one message.\n");\r
++ fprintf (stderr, "Error: search term did not match precisely one message (matched %d messages).\n", count);\r
+ return 1;\r
+ }\r
+ \r
+diff --git a/test/T210-raw.sh b/test/T210-raw.sh\r
+index dfea2d19caa9..832a4ad311b7 100755\r
+--- a/test/T210-raw.sh\r
++++ b/test/T210-raw.sh\r
+@@ -8,7 +8,7 @@ add_message\r
+ \r
+ test_begin_subtest "Attempt to show multiple raw messages"\r
+ output=$(notmuch show --format=raw "*" 2>&1)\r
+-test_expect_equal "$output" "Error: search term did not match precisely one message."\r
++test_expect_equal "$output" "Error: search term did not match precisely one message (matched 2 messages)."\r
+ \r
+ test_begin_subtest "Show a raw message"\r
+ output=$(notmuch show --format=raw id:msg-001@notmuch-test-suite | notmuch_date_sanitize)\r
+-- \r
+2.6.4\r
+\r