--- /dev/null
+Return-Path: <jani@nikula.org>\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 971D56DE1607\r
+ for <notmuch@notmuchmail.org>; Thu, 3 Sep 2015 12:40:33 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.422\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.422 tagged_above=-999 required=5 tests=[AWL=0.298,\r
+ RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-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 iRT_XOhNR8o4 for <notmuch@notmuchmail.org>;\r
+ Thu, 3 Sep 2015 12:40:30 -0700 (PDT)\r
+Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com\r
+ [209.85.212.179])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 54C956DE1601\r
+ for <notmuch@notmuchmail.org>; Thu, 3 Sep 2015 12:40:16 -0700 (PDT)\r
+Received: by wicfx3 with SMTP id fx3so1163164wic.1\r
+ for <notmuch@notmuchmail.org>; Thu, 03 Sep 2015 12:40:14 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+ :references:in-reply-to:references;\r
+ bh=hSwKYqPHO7+9nkGxYYNyXcN4RX89T7x7GJPaAR5dNYg=;\r
+ b=bGRuOSwHHkd/YMuowWF84q3M0m1elXTWB9C4Xc0PwmrS5VIetKgpZaAgvVDwJhw3c4\r
+ 67EYhIv9Qmx849jOtZ6Pbh5nKojohBZ7umNTa3gkvfKz9kzIRWsVqVhokfcwBrNyWSH2\r
+ JE3DbJaXTxWNOg3r+j/dmvJ3/mCoRGlI5+FlaenRTn9KSpznMDMIUBz+xV6d0s+oWfGP\r
+ 1zJ5G4wp8frAi9LcaTmcgZ8kcIMPRv0F0ZVP2IE/99CLUx+ixaxy+OSdRH8CiD/Z/p3n\r
+ WGN9g8YDrPN/8ipKdS62W981PDLVD3Od52KBGrYggkAZ/Kjvdhq93QvfjKEBuH7Pokv5\r
+ TmGA==\r
+X-Gm-Message-State:\r
+ ALoCoQlaEuF0IG80aLWP/8NIjqrDVeecBRTgcnTq+D1AKBKJpuxnzMH/iSsbI6K3neYZkxDQJQCt\r
+X-Received: by 10.180.99.66 with SMTP id eo2mr2475724wib.88.1441309214443;\r
+ Thu, 03 Sep 2015 12:40:14 -0700 (PDT)\r
+Received: from localhost (mobile-access-bcee4f-131.dhcp.inet.fi.\r
+ [188.238.79.131])\r
+ by smtp.gmail.com with ESMTPSA id eu10sm646836wib.5.2015.09.03.12.40.13\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Thu, 03 Sep 2015 12:40:14 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 3/9] cli: add support for not deduplicating notmuch address\r
+ results\r
+Date: Thu, 3 Sep 2015 22:39:59 +0300\r
+Message-Id:\r
+ <fd59eadee26a770097517bee038e2b126e11aa90.1441308761.git.jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <cover.1441308761.git.jani@nikula.org>\r
+References: <cover.1441308761.git.jani@nikula.org>\r
+In-Reply-To: <cover.1441308761.git.jani@nikula.org>\r
+References: <cover.1441308761.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\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: Thu, 03 Sep 2015 19:40:33 -0000\r
+\r
+Make it possible to use notmuch address as part of a | sort | uniq -c\r
+pipe instead of forcing --output=count. This is useful for combining\r
+results from multiple notmuch address queries.\r
+---\r
+ notmuch-search.c | 21 ++++++++++++++++++++-\r
+ 1 file changed, 20 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 36f58eb8d54c..66404b561679 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -37,12 +37,18 @@ typedef enum {\r
+ } output_t;\r
+ \r
+ typedef enum {\r
++ DEDUP_NONE,\r
++ DEDUP_MAILBOX,\r
++} dedup_t;\r
++\r
++typedef enum {\r
+ NOTMUCH_FORMAT_JSON,\r
+ NOTMUCH_FORMAT_TEXT,\r
+ NOTMUCH_FORMAT_TEXT0,\r
+ NOTMUCH_FORMAT_SEXP\r
+ } format_sel_t;\r
+ \r
++\r
+ typedef struct {\r
+ notmuch_database_t *notmuch;\r
+ format_sel_t format_sel;\r
+@@ -55,6 +61,7 @@ typedef struct {\r
+ int limit;\r
+ int dupe;\r
+ GHashTable *addresses;\r
++ dedup_t dedup;\r
+ } search_context_t;\r
+ \r
+ typedef struct {\r
+@@ -355,7 +362,9 @@ process_address_list (const search_context_t *ctx,\r
+ .count = 0,\r
+ };\r
+ \r
+- if (is_duplicate (ctx, mbx.name, mbx.addr))\r
++ /* OUTPUT_COUNT only works with deduplication */\r
++ if (ctx->dedup != DEDUP_NONE &&\r
++ is_duplicate (ctx, mbx.name, mbx.addr))\r
+ continue;\r
+ \r
+ if (ctx->output & OUTPUT_COUNT)\r
+@@ -656,6 +665,7 @@ static search_context_t search_context = {\r
+ .offset = 0,\r
+ .limit = -1, /* unlimited */\r
+ .dupe = -1,\r
++ .dedup = DEDUP_MAILBOX,\r
+ };\r
+ \r
+ static const notmuch_opt_desc_t common_options[] = {\r
+@@ -755,6 +765,10 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])\r
+ (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },\r
+ { "false", NOTMUCH_EXCLUDE_FALSE },\r
+ { 0, 0 } } },\r
++ { NOTMUCH_OPT_KEYWORD, &ctx->dedup, "deduplicate", 'D',\r
++ (notmuch_keyword_t []){ { "no", DEDUP_NONE },\r
++ { "mailbox", DEDUP_MAILBOX },\r
++ { 0, 0 } } },\r
+ { NOTMUCH_OPT_INHERIT, (void *) &common_options, NULL, 0, 0 },\r
+ { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },\r
+ { 0, 0, 0, 0, 0 }\r
+@@ -769,6 +783,11 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])\r
+ if (! (ctx->output & (OUTPUT_SENDER | OUTPUT_RECIPIENTS)))\r
+ ctx->output |= OUTPUT_SENDER;\r
+ \r
++ if (ctx->output & OUTPUT_COUNT && ctx->dedup == DEDUP_NONE) {\r
++ fprintf (stderr, "--output=count is not applicable with --deduplicate=no\n");\r
++ return EXIT_FAILURE;\r
++ }\r
++\r
+ if (_notmuch_search_prepare (ctx, config,\r
+ argc - opt_index, argv + opt_index))\r
+ return EXIT_FAILURE;\r
+-- \r
+2.1.4\r
+\r