--- /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 5EE336DE3948\r
+ for <notmuch@notmuchmail.org>; Sat, 13 Aug 2016 04:41:27 -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.261\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.261 tagged_above=-999 required=5 tests=[AWL=0.981, \r
+ DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7,\r
+ RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] 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 Uh3o7gtWwd6T for <notmuch@notmuchmail.org>;\r
+ Sat, 13 Aug 2016 04:41:19 -0700 (PDT)\r
+Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com\r
+ [74.125.82.66]) by arlo.cworth.org (Postfix) with ESMTPS id 88BF26DE38C3 for\r
+ <notmuch@notmuchmail.org>; Sat, 13 Aug 2016 04:39:21 -0700 (PDT)\r
+Received: by mail-wm0-f66.google.com with SMTP id i138so2004722wmf.3\r
+ for <notmuch@notmuchmail.org>; Sat, 13 Aug 2016 04:39:21 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=nikula-org.20150623.gappssmtp.com; s=20150623;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references\r
+ :in-reply-to:references;\r
+ bh=FgEWcwZwZNHGDLoYAMew8rAbVt2GXziMhF5ZA3VKnBg=;\r
+ b=yxyVfzifAIjSe86Va0b+vOpw4OF4cY+tI+gB+Z6wGFAP+Q6j8oFqNHLK20fH6iG5rY\r
+ L6nZVvnSlNtd+D+nfPfkOn23r84yZUFI5N0icQ7SS8FYKCS/0m7RKhC5b9vdCorXVwIr\r
+ eCcJKN13HI8h7zXTeQPhWBjCTd9HtEEtmcQHeYE8Da71wowbcv9nSGYDTSgLOJPPYHcs\r
+ fnlCW29CzKmXhqpW/tSbmgZz5m3jlifOHHwKGLRg3ON2ZRxqBxpEovUiR/5jH55BOhUi\r
+ IuoCygv5h6a3mWgCW662Gif+sHc8x2K6P6zETzKv022TR7ZH3n+KgJnIaYzv08R/u/TG\r
+ IF7Q==\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=FgEWcwZwZNHGDLoYAMew8rAbVt2GXziMhF5ZA3VKnBg=;\r
+ b=ZZbk6isgkyl5mgkEsivzj+5d5A1Wib6XL/AWDmLfE05Z2wTnsy8aWI/oMARHOPQMO/\r
+ 4a5JFmsMipnsvtr6NCkFyye06ueHz6y2980YSAlqLA6cRPX99foGo2f10jCW1hLlfVJe\r
+ T6Qwt5dRwbiH2dMEC+cHiKwky6T7cpRtqVKfr2nit6Xf/cPmX2ytjIWDFedYbAne98mv\r
+ g2XSGWrv9eVBSXaXt0YCfbR1cWWXKPpFBpX1zhRucYOzPKyapyS7ig+gQUkxSlKU77zY\r
+ jB7xdiponE1KULsLSZLCMi1WYwkKYs1a65+ojzOOkhbBNN2V8KSlh5pmeSzMpqaPZU2N\r
+ E02A==\r
+X-Gm-Message-State:\r
+ AEkoousLcqwQxAqKNS6kdqXJanpkx88CrEXZcTk1HBfdbIna+cAhRcuJJYCTNualKeSX8w==\r
+X-Received: by 10.28.38.196 with SMTP id m187mr3227141wmm.81.1471088360208;\r
+ Sat, 13 Aug 2016 04:39:20 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c368-70.dhcp.inet.fi.\r
+ [88.195.104.70])\r
+ by smtp.gmail.com with ESMTPSA id d64sm6799981wmc.22.2016.08.13.04.39.19\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Sat, 13 Aug 2016 04:39:19 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Cc: Daniel Kahn Gillmor <dkg@fifthhorseman.net>,\r
+ jani@nikula.org\r
+Subject: [PATCH v2 12/14] cli/reply: pass internet address list to munge\r
+ detect\r
+Date: Sat, 13 Aug 2016 14:37:36 +0300\r
+Message-Id:\r
+ <2bdf4c7e53829fed525671f9f8f874323737f814.1471088022.git.jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <cover.1471088022.git.jani@nikula.org>\r
+References: <cover.1471088022.git.jani@nikula.org>\r
+In-Reply-To: <cover.1471088022.git.jani@nikula.org>\r
+References: <cover.1471088022.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 13 Aug 2016 11:41:27 -0000\r
+\r
+---\r
+ notmuch-reply.c | 20 ++++++++++++--------\r
+ 1 file changed, 12 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index 98034485c546..cf4248bd6794 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -231,19 +231,18 @@ scan_address_list (InternetAddressList *list,\r
+ * in either the 'To' or 'Cc' header of the message?\r
+ */\r
+ static int\r
+-reply_to_header_is_redundant (notmuch_message_t *message, const char *reply_to)\r
++reply_to_header_is_redundant (notmuch_message_t *message,\r
++ InternetAddressList *reply_to_list)\r
+ {\r
+ const char *to, *cc, *addr;\r
+- InternetAddressList *list;\r
+ InternetAddress *address;\r
+ InternetAddressMailbox *mailbox;\r
+ \r
+- list = internet_address_list_parse_string (reply_to);\r
+-\r
+- if (internet_address_list_length (list) != 1)\r
++ if (reply_to_list == NULL ||\r
++ internet_address_list_length (reply_to_list) != 1)\r
+ return 0;\r
+ \r
+- address = internet_address_list_get_address (list, 0);\r
++ address = internet_address_list_get_address (reply_to_list, 0);\r
+ if (INTERNET_ADDRESS_IS_GROUP (address))\r
+ return 0;\r
+ \r
+@@ -269,6 +268,8 @@ static InternetAddressList *get_sender(notmuch_message_t *message,\r
+ \r
+ reply_to = g_mime_message_get_reply_to (mime_message);\r
+ if (reply_to && *reply_to) {\r
++ InternetAddressList *reply_to_list;\r
++\r
+ /*\r
+ * Some mailing lists munge the Reply-To header despite it\r
+ * being A Bad Thing, see\r
+@@ -282,8 +283,11 @@ static InternetAddressList *get_sender(notmuch_message_t *message,\r
+ * to the list. Note that the address in the Reply-To header\r
+ * will always appear in the reply if reply_all is true.\r
+ */\r
+- if (! reply_to_header_is_redundant (message, reply_to))\r
+- return internet_address_list_parse_string (reply_to);\r
++ reply_to_list = internet_address_list_parse_string (reply_to);\r
++ if (! reply_to_header_is_redundant (message, reply_to_list))\r
++ return reply_to_list;\r
++\r
++ g_object_unref (G_OBJECT (reply_to_list));\r
+ }\r
+ \r
+ return internet_address_list_parse_string (\r
+-- \r
+2.1.4\r
+\r