From 60c6a521779b5763e495801571f713a580fce18a Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Sat, 7 May 2016 22:24:18 +0300 Subject: [PATCH] [PATCH] cli: tell how many messages were precisely matched when expected 1 match --- 72/40f58df90ae52474e2d2af409b6d690cdd67ab | 100 ++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 72/40f58df90ae52474e2d2af409b6d690cdd67ab diff --git a/72/40f58df90ae52474e2d2af409b6d690cdd67ab b/72/40f58df90ae52474e2d2af409b6d690cdd67ab new file mode 100644 index 000000000..b21a52b19 --- /dev/null +++ b/72/40f58df90ae52474e2d2af409b6d690cdd67ab @@ -0,0 +1,100 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 3E7676DE0217 + for ; Sat, 7 May 2016 12:24:29 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.265 +X-Spam-Level: +X-Spam-Status: No, score=0.265 tagged_above=-999 required=5 tests=[AWL=0.274, + HEADER_FROM_DIFFERENT_DOMAINS=0.001, T_RP_MATCHES_RCVD=-0.01] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id skPLeK_ClONd for ; + Sat, 7 May 2016 12:24:21 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by arlo.cworth.org (Postfix) with ESMTP id 5DF3C6DE00EB + for ; Sat, 7 May 2016 12:24:21 -0700 (PDT) +Received: by guru.guru-group.fi (Postfix, from userid 501) + id 492F0100227; Sat, 7 May 2016 22:24:20 +0300 (EEST) +From: Tomi Ollila +To: notmuch@notmuchmail.org +Cc: tomi.ollila@iki.fi +Subject: [PATCH] cli: tell how many messages were precisely matched when + expected 1 match +Date: Sat, 7 May 2016 22:24:18 +0300 +Message-Id: <1462649058-5330-1-git-send-email-tomi.ollila@iki.fi> +X-Mailer: git-send-email 2.6.4 +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 07 May 2016 19:24:29 -0000 + +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 messages) to the error message it +makes the problem more understandable (e.g when 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 + -- 2.26.2