unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] cli: tell how many messages were precisely matched when expected 1 match
@ 2016-05-07 19:24 Tomi Ollila
  2016-05-19 11:05 ` David Bremner
  0 siblings, 1 reply; 2+ messages in thread
From: Tomi Ollila @ 2016-05-07 19:24 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

In case of notmuch reply and notmuch show --part=N it is required that
search terms match to one message. If match count was != 1, error
message "Error: search term did not match precisely one message"
was too vague to explain what happened.

By appending (matched <num> messages) to the error message it
makes the problem more understandable (e.g when <num> is '0'
user reckons the query had a typo in it).
---
 notmuch-reply.c  | 2 +-
 notmuch-show.c   | 2 +-
 test/T210-raw.sh | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 3c6d685cbd60..a74194a31e4f 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -664,7 +664,7 @@ notmuch_reply_format_sprinter(void *ctx,
 	return 1;
 
     if (count != 1) {
-	fprintf (stderr, "Error: search term did not match precisely one message.\n");
+	fprintf (stderr, "Error: search term did not match precisely one message (matched %d messages).\n", count);
 	return 1;
     }
 
diff --git a/notmuch-show.c b/notmuch-show.c
index 87e52bbc0e81..3d5033d644b3 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -904,7 +904,7 @@ do_show_single (void *ctx,
 	return 1;
 
     if (count != 1) {
-	fprintf (stderr, "Error: search term did not match precisely one message.\n");
+	fprintf (stderr, "Error: search term did not match precisely one message (matched %d messages).\n", count);
 	return 1;
     }
 
diff --git a/test/T210-raw.sh b/test/T210-raw.sh
index dfea2d19caa9..832a4ad311b7 100755
--- a/test/T210-raw.sh
+++ b/test/T210-raw.sh
@@ -8,7 +8,7 @@ add_message
 
 test_begin_subtest "Attempt to show multiple raw messages"
 output=$(notmuch show --format=raw "*" 2>&1)
-test_expect_equal "$output" "Error: search term did not match precisely one message."
+test_expect_equal "$output" "Error: search term did not match precisely one message (matched 2 messages)."
 
 test_begin_subtest "Show a raw message"
 output=$(notmuch show --format=raw id:msg-001@notmuch-test-suite | notmuch_date_sanitize)
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] cli: tell how many messages were precisely matched when expected 1 match
  2016-05-07 19:24 [PATCH] cli: tell how many messages were precisely matched when expected 1 match Tomi Ollila
@ 2016-05-19 11:05 ` David Bremner
  0 siblings, 0 replies; 2+ messages in thread
From: David Bremner @ 2016-05-19 11:05 UTC (permalink / raw)
  To: Tomi Ollila, notmuch; +Cc: tomi.ollila

Tomi Ollila <tomi.ollila@iki.fi> writes:

> In case of notmuch reply and notmuch show --part=N it is required that
> search terms match to one message. If match count was != 1, error
> message "Error: search term did not match precisely one message"
> was too vague to explain what happened.
>
> By appending (matched <num> messages) to the error message it
> makes the problem more understandable (e.g when <num> is '0'
> user reckons the query had a typo in it).

pushed,

d

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-05-19 11:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-07 19:24 [PATCH] cli: tell how many messages were precisely matched when expected 1 match Tomi Ollila
2016-05-19 11:05 ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).