--- /dev/null
+Return-Path: <m.walters@qmul.ac.uk>\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 17150431FBC\r
+ for <notmuch@notmuchmail.org>; Fri, 31 Oct 2014 17:22:45 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+ tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+ NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 KilGQ2SlyKqr for <notmuch@notmuchmail.org>;\r
+ Fri, 31 Oct 2014 17:22:37 -0700 (PDT)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 1F04B431FAF\r
+ for <notmuch@notmuchmail.org>; Fri, 31 Oct 2014 17:22:37 -0700 (PDT)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+ by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1XkMSJ-0000jQ-3Z; Sat, 01 Nov 2014 00:22:35 +0000\r
+Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost)\r
+ by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1XkMSH-0006JP-Oy; Sat, 01 Nov 2014 00:22:10 +0000\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Michal Sojka <sojkam1@fel.cvut.cz>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v6 0/7] notmuch search --output=sender/recipients\r
+In-Reply-To: <1414792441-29555-1-git-send-email-sojkam1@fel.cvut.cz>\r
+References: <1414792441-29555-1-git-send-email-sojkam1@fel.cvut.cz>\r
+User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Sat, 01 Nov 2014 00:22:07 +0000\r
+Message-ID: <87tx2ju5w0.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+X-Sender-Host-Address: 87.81.223.162\r
+X-QM-Geographic: According to ripencc,\r
+ this message was delivered by a machine in Britain (UK) (GB).\r
+X-QM-SPAM-Info: Sender has good ham record. :)\r
+X-QM-Body-MD5: ccef3859bca877dfaa292ff380dd453b (of first 20000 bytes)\r
+X-SpamAssassin-Score: -0.1\r
+X-SpamAssassin-SpamBar: /\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+ determine if it is\r
+ spam. We require at least 5.0 points to mark a message as spam.\r
+ This message scored -0.1 points.\r
+ Summary of the scoring: \r
+ * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+ provider * (markwalters1009[at]gmail.com)\r
+ * -0.1 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\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: Sat, 01 Nov 2014 00:22:45 -0000\r
+\r
+\r
+On Fri, 31 Oct 2014, Michal Sojka <sojkam1@fel.cvut.cz> wrote:\r
+> Hi all,\r
+>\r
+> this is v6 of the search --output=3Daddress series. It obsoletes v5\r
+> (id:1414713573-21461-1-git-send-email-sojkam1@fel.cvut.cz).\r
+\r
+I have tested patches 1-5 and they LGTM. +1 from me.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+> Changes from v5 (full diff below):\r
+>\r
+> - Added quoting of name parts if that is necessary (pointed out by\r
+> Mark Walters). Structured formats contain both full address\r
+> (possibly with quoted name) and unquoted individual fields.\r
+> - Fixed bug in --output=3Dcount --filter-by=3D*fold (reported by Jesse\r
+> Rosenthal). New test was added for this case. Fixing the bug also\r
+> resulted in simpler code :)\r
+> - Added missing unreferencing of InternetAddressList.\r
+>\r
+> Changes from v4:\r
+>\r
+> - patch changed to commit in commit messages\r
+> - opt->format changed to format\r
+> - Added comments to process_* functions\r
+> - duplicite changed to duplicate\r
+> - check_duplicate changed to is_duplicate\r
+> - Deduplication was split into two commits: basic deduplication\r
+> without a command line option and configurable deduplication with\r
+> --fiter-by.\r
+>\r
+> Changes from v3:\r
+>\r
+> - `o' renamed to `opt'.\r
+> - Conversion of --output from keyword to keyword-flags is now a\r
+> separate patch.\r
+> - Structured output formats print name and address separately.\r
+> - Added test for --format=3Djson.\r
+> - Changed --filter-by default to nameaddr. In v2, the default was\r
+> addrfold, in v3 the default was no filtering at all. I believe that\r
+> Mark's suggestion to make nameaddr the default is good trade off.\r
+> - Added new --output=3Dcount\r
+> - Minor style fixes\r
+> - Few typos fixed\r
+> - There is no way to output unfiltered (duplicite) addresses.\r
+> Hopefully, the introduction of --output=3Dcount is sufficient\r
+> replacement for this "feature".\r
+>\r
+> Cheers,\r
+> -Michal\r
+>\r
+>\r
+> Jani Nikula (1):\r
+> cli: Add support for parsing keyword-flag arguments\r
+>\r
+> Michal Sojka (6):\r
+> cli: search: Refactor passing of command line options\r
+> cli: search: Convert --output to keyword-flag argument\r
+> cli: search: Add --output=3D{sender,recipients}\r
+> cli: search: Do not output duplicate addresses\r
+> cli: search: Add --output=3Dcount\r
+> cli: search: Add --filter-by option to configure address filtering\r
+>\r
+> command-line-arguments.c | 6 +-\r
+> command-line-arguments.h | 1 +\r
+> completion/notmuch-completion.bash | 8 +-\r
+> completion/notmuch-completion.zsh | 4 +-\r
+> doc/man1/notmuch-search.rst | 66 ++++++-\r
+> notmuch-search.c | 390 +++++++++++++++++++++++++++++--=\r
+------\r
+> test/T090-search-output.sh | 87 +++++++++\r
+> test/T095-search-filter-by.sh | 73 +++++++\r
+> test/T410-argument-parsing.sh | 3 +-\r
+> test/arg-test.c | 9 +\r
+> 10 files changed, 565 insertions(+), 82 deletions(-)\r
+> create mode 100755 test/T095-search-filter-by.sh\r
+>\r
+> --=20\r
+> 2.1.1\r
+>\r
+> diff --git a/notmuch-search.c b/notmuch-search.c\r
+> index 8bc80d3..a350f06 100644\r
+> --- a/notmuch-search.c\r
+> +++ b/notmuch-search.c\r
+> @@ -246,33 +246,35 @@ is_duplicate (const search_options_t *opt, GHashTab=\r
+le *addrs, const char *name,\r
+> {\r
+> notmuch_bool_t duplicate;\r
+> char *key;\r
+> + gchar *addrfold =3D NULL;\r
+> mailbox_t *mailbox;\r
+>=20=20\r
+> if (opt->filter_by =3D=3D FILTER_BY_ADDRFOLD ||\r
+> - opt->filter_by =3D=3D FILTER_BY_NAMEADDRFOLD) {\r
+> - gchar *folded =3D g_utf8_casefold (addr, -1);\r
+> - addr =3D talloc_strdup (opt->format, folded);\r
+> - g_free (folded);\r
+> - }\r
+> + opt->filter_by =3D=3D FILTER_BY_NAMEADDRFOLD)\r
+> + addrfold =3D g_utf8_casefold (addr, -1);\r
+> +\r
+> switch (opt->filter_by) {\r
+> case FILTER_BY_NAMEADDR:\r
+> - case FILTER_BY_NAMEADDRFOLD:\r
+> key =3D talloc_asprintf (opt->format, "%s <%s>", name, addr);\r
+> break;\r
+> + case FILTER_BY_NAMEADDRFOLD:\r
+> + key =3D talloc_asprintf (opt->format, "%s <%s>", name, addrfold);\r
+> + break;\r
+> case FILTER_BY_NAME:\r
+> key =3D talloc_strdup (opt->format, name); /* !name results in !key */\r
+> break;\r
+> case FILTER_BY_ADDR:\r
+> - case FILTER_BY_ADDRFOLD:\r
+> key =3D talloc_strdup (opt->format, addr);\r
+> break;\r
+> + case FILTER_BY_ADDRFOLD:\r
+> + key =3D talloc_strdup (opt->format, addrfold);\r
+> + break;\r
+> default:\r
+> INTERNAL_ERROR("invalid --filter-by flags");\r
+> }\r
+>=20=20\r
+> - if (opt->filter_by =3D=3D FILTER_BY_ADDRFOLD ||\r
+> - opt->filter_by =3D=3D FILTER_BY_NAMEADDRFOLD)\r
+> - talloc_free ((char*)addr);\r
+> + if (addrfold)\r
+> + g_free (addrfold);\r
+>=20=20\r
+> if (! key)\r
+> return FALSE;\r
+> @@ -300,33 +302,28 @@ print_mailbox (const search_options_t *opt, const m=\r
+ailbox_t *mailbox)\r
+> const char *addr =3D mailbox->addr;\r
+> int count =3D mailbox->count;\r
+> sprinter_t *format =3D opt->format;\r
+> + InternetAddress *ia =3D internet_address_mailbox_new (name, addr);\r
+> + char *name_addr;\r
+>=20=20\r
+> - if (format->is_text_printer) {\r
+> - char *mailbox_str;\r
+> + /* name_addr has the name part quoted if necessary. Compare\r
+> + * 'John Doe <john@doe.com>' vs. '"Doe, John" <john@doe.com>' */\r
+> + name_addr =3D internet_address_to_string (ia, FALSE);\r
+>=20=20\r
+> - if (name && *name)\r
+> - mailbox_str =3D talloc_asprintf (format, "%s <%s>", name, addr);\r
+> - else\r
+> - mailbox_str =3D talloc_strdup (format, addr);\r
+> -\r
+> - if (! mailbox_str) {\r
+> - fprintf (stderr, "Error: out of memory\n");\r
+> - return;\r
+> - }\r
+> + if (format->is_text_printer) {\r
+> if (count > 0) {\r
+> format->integer (format, count);\r
+> format->string (format, "\t");\r
+> }\r
+> - format->string (format, mailbox_str);\r
+> + format->string (format, name_addr);\r
+> format->separator (format);\r
+> -\r
+> - talloc_free (mailbox_str);\r
+> } else {\r
+> format->begin_map (format);\r
+> format->map_key (format, "name");\r
+> format->string (format, name);\r
+> format->map_key (format, "address");\r
+> format->string (format, addr);\r
+> + format->map_key (format, "name-addr");\r
+> + format->string (format, name_addr);\r
+> if (count > 0) {\r
+> format->map_key (format, "count");\r
+> format->integer (format, count);\r
+> @@ -334,6 +331,9 @@ print_mailbox (const search_options_t *opt, const mai=\r
+lbox_t *mailbox)\r
+> format->end (format);\r
+> format->separator (format);\r
+> }\r
+> +\r
+> + g_object_unref (ia);\r
+> + g_free (name_addr);\r
+> }\r
+>=20=20\r
+> /* Print or prepare for printing addresses from InternetAddressList. */\r
+> @@ -389,6 +389,8 @@ process_address_header (const search_options_t *opt, =\r
+GHashTable *addrs, const ch\r
+> return;\r
+>=20=20\r
+> process_address_list (opt, addrs, list);\r
+> +\r
+> + g_object_unref (list);\r
+> }\r
+>=20=20\r
+> static void\r
+> diff --git a/test/T090-search-output.sh b/test/T090-search-output.sh\r
+> index 5a9bbc9..82380ac 100755\r
+> --- a/test/T090-search-output.sh\r
+> +++ b/test/T090-search-output.sh\r
+> @@ -413,73 +413,23 @@ test_expect_equal_file OUTPUT EXPECTED\r
+> test_begin_subtest "--output=3Dsender --format=3Djson"\r
+> notmuch search --output=3Dsender --format=3Djson '*' >OUTPUT\r
+> cat <<EOF >EXPECTED\r
+> -[{"name": "Fran=C3=A7ois Boulogne", "address": "boulogne.f@gmail.com"},\r
+> -{"name": "Olivier Berger", "address": "olivier.berger@it-sudparis.eu"},\r
+> -{"name": "Chris Wilson", "address": "chris@chris-wilson.co.uk"},\r
+> -{"name": "Carl Worth", "address": "cworth@cworth.org"},\r
+> -{"name": "Alexander Botero-Lowry", "address": "alex.boterolowry@gmail.co=\r
+m"},\r
+> -{"name": "Keith Packard", "address": "keithp@keithp.com"},\r
+> -{"name": "Jjgod Jiang", "address": "gzjjgod@gmail.com"},\r
+> -{"name": "Rolland Santimano", "address": "rollandsantimano@yahoo.com"},\r
+> -{"name": "Jan Janak", "address": "jan@ryngle.com"},\r
+> -{"name": "Stewart Smith", "address": "stewart@flamingspork.com"},\r
+> -{"name": "Lars Kellogg-Stedman", "address": "lars@seas.harvard.edu"},\r
+> -{"name": "Alex Botero-Lowry", "address": "alex.boterolowry@gmail.com"},\r
+> -{"name": "Ingmar Vanhassel", "address": "ingmar@exherbo.org"},\r
+> -{"name": "Aron Griffis", "address": "agriffis@n01se.net"},\r
+> -{"name": "Adrian Perez de Castro", "address": "aperez@igalia.com"},\r
+> -{"name": "Israel Herraiz", "address": "isra@herraiz.org"},\r
+> -{"name": "Mikhail Gusarov", "address": "dottedmag@dottedmag.net"}]\r
+> -EOF\r
+> -test_expect_equal_file OUTPUT EXPECTED\r
+> -\r
+> -test_begin_subtest "--output=3Dsender --output=3Dcount"\r
+> -notmuch search --output=3Dsender --output=3Dcount '*' | sort -n >OUTPUT\r
+> -cat <<EOF >EXPECTED\r
+> -1 Adrian Perez de Castro <aperez@igalia.com>\r
+> -1 Aron Griffis <agriffis@n01se.net>\r
+> -1 Chris Wilson <chris@chris-wilson.co.uk>\r
+> -1 Fran=C3=A7ois Boulogne <boulogne.f@gmail.com>\r
+> -1 Ingmar Vanhassel <ingmar@exherbo.org>\r
+> -1 Israel Herraiz <isra@herraiz.org>\r
+> -1 Olivier Berger <olivier.berger@it-sudparis.eu>\r
+> -1 Rolland Santimano <rollandsantimano@yahoo.com>\r
+> -2 Alex Botero-Lowry <alex.boterolowry@gmail.com>\r
+> -2 Jjgod Jiang <gzjjgod@gmail.com>\r
+> -3 Stewart Smith <stewart@flamingspork.com>\r
+> -4 Alexander Botero-Lowry <alex.boterolowry@gmail.com>\r
+> -4 Jan Janak <jan@ryngle.com>\r
+> -5 Lars Kellogg-Stedman <lars@seas.harvard.edu>\r
+> -5 Mikhail Gusarov <dottedmag@dottedmag.net>\r
+> -7 Keith Packard <keithp@keithp.com>\r
+> -12 Carl Worth <cworth@cworth.org>\r
+> -EOF\r
+> -test_expect_equal_file OUTPUT EXPECTED\r
+> -\r
+> -test_begin_subtest "--output=3Dsender --output=3Dcount --format=3Djson"\r
+> -# Since the iteration order of GHashTable is not specified, we\r
+> -# preprocess and sort the results to keep the order stable here.\r
+> -notmuch search --output=3Dsender --output=3Dcount --format=3Djson '*' | \\r
+> - sed -e 's/^\[//' -e 's/]$//' -e 's/,$//' | \\r
+> - sort --field-separator=3D":" --key=3D4n --key=3D2 >OUTPUT\r
+> -cat <<EOF >EXPECTED\r
+> -{"name": "Adrian Perez de Castro", "address": "aperez@igalia.com", "coun=\r
+t": 1}\r
+> -{"name": "Aron Griffis", "address": "agriffis@n01se.net", "count": 1}\r
+> -{"name": "Chris Wilson", "address": "chris@chris-wilson.co.uk", "count":=\r
+ 1}\r
+> -{"name": "Fran=C3=A7ois Boulogne", "address": "boulogne.f@gmail.com", "c=\r
+ount": 1}\r
+> -{"name": "Ingmar Vanhassel", "address": "ingmar@exherbo.org", "count": 1}\r
+> -{"name": "Israel Herraiz", "address": "isra@herraiz.org", "count": 1}\r
+> -{"name": "Olivier Berger", "address": "olivier.berger@it-sudparis.eu", "=\r
+count": 1}\r
+> -{"name": "Rolland Santimano", "address": "rollandsantimano@yahoo.com", "=\r
+count": 1}\r
+> -{"name": "Alex Botero-Lowry", "address": "alex.boterolowry@gmail.com", "=\r
+count": 2}\r
+> -{"name": "Jjgod Jiang", "address": "gzjjgod@gmail.com", "count": 2}\r
+> -{"name": "Stewart Smith", "address": "stewart@flamingspork.com", "count"=\r
+: 3}\r
+> -{"name": "Alexander Botero-Lowry", "address": "alex.boterolowry@gmail.co=\r
+m", "count": 4}\r
+> -{"name": "Jan Janak", "address": "jan@ryngle.com", "count": 4}\r
+> -{"name": "Lars Kellogg-Stedman", "address": "lars@seas.harvard.edu", "co=\r
+unt": 5}\r
+> -{"name": "Mikhail Gusarov", "address": "dottedmag@dottedmag.net", "count=\r
+": 5}\r
+> -{"name": "Keith Packard", "address": "keithp@keithp.com", "count": 7}\r
+> -{"name": "Carl Worth", "address": "cworth@cworth.org", "count": 12}\r
+> +[{"name": "Fran=C3=A7ois Boulogne", "address": "boulogne.f@gmail.com", "=\r
+name-addr": "Fran=C3=A7ois Boulogne <boulogne.f@gmail.com>"},\r
+> +{"name": "Olivier Berger", "address": "olivier.berger@it-sudparis.eu", "=\r
+name-addr": "Olivier Berger <olivier.berger@it-sudparis.eu>"},\r
+> +{"name": "Chris Wilson", "address": "chris@chris-wilson.co.uk", "name-ad=\r
+dr": "Chris Wilson <chris@chris-wilson.co.uk>"},\r
+> +{"name": "Carl Worth", "address": "cworth@cworth.org", "name-addr": "Car=\r
+l Worth <cworth@cworth.org>"},\r
+> +{"name": "Alexander Botero-Lowry", "address": "alex.boterolowry@gmail.co=\r
+m", "name-addr": "Alexander Botero-Lowry <alex.boterolowry@gmail.com>"},\r
+> +{"name": "Keith Packard", "address": "keithp@keithp.com", "name-addr": "=\r
+Keith Packard <keithp@keithp.com>"},\r
+> +{"name": "Jjgod Jiang", "address": "gzjjgod@gmail.com", "name-addr": "Jj=\r
+god Jiang <gzjjgod@gmail.com>"},\r
+> +{"name": "Rolland Santimano", "address": "rollandsantimano@yahoo.com", "=\r
+name-addr": "Rolland Santimano <rollandsantimano@yahoo.com>"},\r
+> +{"name": "Jan Janak", "address": "jan@ryngle.com", "name-addr": "Jan Jan=\r
+ak <jan@ryngle.com>"},\r
+> +{"name": "Stewart Smith", "address": "stewart@flamingspork.com", "name-a=\r
+ddr": "Stewart Smith <stewart@flamingspork.com>"},\r
+> +{"name": "Lars Kellogg-Stedman", "address": "lars@seas.harvard.edu", "na=\r
+me-addr": "Lars Kellogg-Stedman <lars@seas.harvard.edu>"},\r
+> +{"name": "Alex Botero-Lowry", "address": "alex.boterolowry@gmail.com", "=\r
+name-addr": "Alex Botero-Lowry <alex.boterolowry@gmail.com>"},\r
+> +{"name": "Ingmar Vanhassel", "address": "ingmar@exherbo.org", "name-addr=\r
+": "Ingmar Vanhassel <ingmar@exherbo.org>"},\r
+> +{"name": "Aron Griffis", "address": "agriffis@n01se.net", "name-addr": "=\r
+Aron Griffis <agriffis@n01se.net>"},\r
+> +{"name": "Adrian Perez de Castro", "address": "aperez@igalia.com", "name=\r
+-addr": "Adrian Perez de Castro <aperez@igalia.com>"},\r
+> +{"name": "Israel Herraiz", "address": "isra@herraiz.org", "name-addr": "=\r
+Israel Herraiz <isra@herraiz.org>"},\r
+> +{"name": "Mikhail Gusarov", "address": "dottedmag@dottedmag.net", "name-=\r
+addr": "Mikhail Gusarov <dottedmag@dottedmag.net>"}]\r
+> EOF\r
+> test_expect_equal_file OUTPUT EXPECTED\r
+>=20=20\r
+> @@ -487,7 +437,7 @@ test_begin_subtest "--output=3Drecipients"\r
+> notmuch search --output=3Drecipients '*' >OUTPUT\r
+> cat <<EOF >EXPECTED\r
+> Allan McRae <allan@archlinux.org>\r
+> -Discussion about the Arch User Repository (AUR) <aur-general@archlinux.o=\r
+rg>\r
+> +"Discussion about the Arch User Repository (AUR)" <aur-general@archlinux=\r
+.org>\r
+> olivier.berger@it-sudparis.eu\r
+> notmuch@notmuchmail.org\r
+> notmuch <notmuch@notmuchmail.org>\r
+> @@ -501,7 +451,7 @@ notmuch search --output=3Dsender --output=3Drecipient=\r
+s '*' >OUTPUT\r
+> cat <<EOF >EXPECTED\r
+> Fran=C3=A7ois Boulogne <boulogne.f@gmail.com>\r
+> Allan McRae <allan@archlinux.org>\r
+> -Discussion about the Arch User Repository (AUR) <aur-general@archlinux.o=\r
+rg>\r
+> +"Discussion about the Arch User Repository (AUR)" <aur-general@archlinux=\r
+.org>\r
+> Olivier Berger <olivier.berger@it-sudparis.eu>\r
+> olivier.berger@it-sudparis.eu\r
+> Chris Wilson <chris@chris-wilson.co.uk>\r
+> diff --git a/test/T095-search-filter-by.sh b/test/T095-search-filter-by.sh\r
+> index 97d9a9b..15c9f77 100755\r
+> --- a/test/T095-search-filter-by.sh\r
+> +++ b/test/T095-search-filter-by.sh\r
+> @@ -2,17 +2,17 @@\r
+> test_description=3D'duplicite address filtering in "notmuch search --out=\r
+put=3Drecipients"'\r
+> . ./test-lib.sh\r
+>=20=20\r
+> -add_message '[to]=3D"Real Name <foo@example.com>, Real Name <bar@example=\r
+.com>"'\r
+> -add_message '[to]=3D"Nickname <foo@example.com>"' '[cc]=3D"Real Name <Ba=\r
+r@Example.COM>"'\r
+> -add_message '[to]=3D"Nickname <foo@example.com>"' '[bcc]=3D"Real Name <B=\r
+ar@Example.COM>"'\r
+> +add_message '[to]=3D"John Doe <foo@example.com>, John Doe <bar@example.c=\r
+om>"'\r
+> +add_message '[to]=3D"\"Doe, John\" <foo@example.com>"' '[cc]=3D"John Doe=\r
+ <Bar@Example.COM>"'\r
+> +add_message '[to]=3D"\"Doe, John\" <foo@example.com>"' '[bcc]=3D"John Do=\r
+e <Bar@Example.COM>"'\r
+>=20=20\r
+> test_begin_subtest "--output=3Drecipients"\r
+> notmuch search --output=3Drecipients "*" >OUTPUT\r
+> cat <<EOF >EXPECTED\r
+> -Real Name <foo@example.com>\r
+> -Real Name <bar@example.com>\r
+> -Nickname <foo@example.com>\r
+> -Real Name <Bar@Example.COM>\r
+> +John Doe <foo@example.com>\r
+> +John Doe <bar@example.com>\r
+> +"Doe, John" <foo@example.com>\r
+> +John Doe <Bar@Example.COM>\r
+> EOF\r
+> test_expect_equal_file OUTPUT EXPECTED\r
+>=20=20\r
+> @@ -20,44 +20,53 @@ test_begin_subtest "--output=3Drecipients --filter-by=\r
+=3Dnameaddr"\r
+> notmuch search --output=3Drecipients --filter-by=3Dnameaddr "*" >OUTPUT\r
+> # The same as above\r
+> cat <<EOF >EXPECTED\r
+> -Real Name <foo@example.com>\r
+> -Real Name <bar@example.com>\r
+> -Nickname <foo@example.com>\r
+> -Real Name <Bar@Example.COM>\r
+> +John Doe <foo@example.com>\r
+> +John Doe <bar@example.com>\r
+> +"Doe, John" <foo@example.com>\r
+> +John Doe <Bar@Example.COM>\r
+> EOF\r
+> test_expect_equal_file OUTPUT EXPECTED\r
+>=20=20\r
+> test_begin_subtest "--output=3Drecipients --filter-by=3Dname"\r
+> notmuch search --output=3Drecipients --filter-by=3Dname "*" >OUTPUT\r
+> cat <<EOF >EXPECTED\r
+> -Real Name <foo@example.com>\r
+> -Nickname <foo@example.com>\r
+> +John Doe <foo@example.com>\r
+> +"Doe, John" <foo@example.com>\r
+> EOF\r
+> test_expect_equal_file OUTPUT EXPECTED\r
+>=20=20\r
+> test_begin_subtest "--output=3Drecipients --filter-by=3Daddr"\r
+> notmuch search --output=3Drecipients --filter-by=3Daddr "*" >OUTPUT\r
+> cat <<EOF >EXPECTED\r
+> -Real Name <foo@example.com>\r
+> -Real Name <bar@example.com>\r
+> -Real Name <Bar@Example.COM>\r
+> +John Doe <foo@example.com>\r
+> +John Doe <bar@example.com>\r
+> +John Doe <Bar@Example.COM>\r
+> EOF\r
+> test_expect_equal_file OUTPUT EXPECTED\r
+>=20=20\r
+> test_begin_subtest "--output=3Drecipients --filter-by=3Daddrfold"\r
+> notmuch search --output=3Drecipients --filter-by=3Daddrfold "*" >OUTPUT\r
+> cat <<EOF >EXPECTED\r
+> -Real Name <foo@example.com>\r
+> -Real Name <bar@example.com>\r
+> +John Doe <foo@example.com>\r
+> +John Doe <bar@example.com>\r
+> EOF\r
+> test_expect_equal_file OUTPUT EXPECTED\r
+>=20=20\r
+> test_begin_subtest "--output=3Drecipients --filter-by=3Dnameaddrfold"\r
+> notmuch search --output=3Drecipients --filter-by=3Dnameaddrfold "*" >OUT=\r
+PUT\r
+> cat <<EOF >EXPECTED\r
+> -Real Name <foo@example.com>\r
+> -Real Name <bar@example.com>\r
+> -Nickname <foo@example.com>\r
+> +John Doe <foo@example.com>\r
+> +John Doe <bar@example.com>\r
+> +"Doe, John" <foo@example.com>\r
+> +EOF\r
+> +test_expect_equal_file OUTPUT EXPECTED\r
+> +\r
+> +test_begin_subtest "--output=3Drecipients --filter-by=3Dnameaddrfold --o=\r
+utput=3Dcount"\r
+> +notmuch search --output=3Drecipients --filter-by=3Dnameaddrfold --output=\r
+=3Dcount "*" | sort -n >OUTPUT\r
+> +cat <<EOF >EXPECTED\r
+> +1 John Doe <foo@example.com>\r
+> +2 "Doe, John" <foo@example.com>\r
+> +3 John Doe <bar@example.com>\r
+> EOF\r
+> test_expect_equal_file OUTPUT EXPECTED\r
+>=20=20\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r