]> git.notmuchmail.org Git - notmuch/commitdiff
cli: tell how many messages were precisely matched when expected 1 match
authorTomi Ollila <tomi.ollila@iki.fi>
Sat, 7 May 2016 19:24:18 +0000 (22:24 +0300)
committerDavid Bremner <david@tethera.net>
Thu, 19 May 2016 10:49:03 +0000 (07:49 -0300)
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
notmuch-show.c
test/T210-raw.sh

index 3c6d685cbd6054c68a0281e696e747c8045aff57..a74194a31e4fc7be9505659a973146fc70a295b2 100644 (file)
@@ -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;
     }
 
index 87e52bbc0e81a7f8b0c4c7ca5c374cfdbb5da068..3d5033d644b36e3950955e2b30d9703e6ca8267b 100644 (file)
@@ -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;
     }
 
index dfea2d19caa93fece9fdbd3dc0ba0fbefd94c828..832a4ad311b708e5b8f86dd2df92d7958fd6c96b 100755 (executable)
@@ -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)