From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id OJt4CcwK4159HgAAsNZ9tg (envelope-from ) for ; Fri, 12 Jun 2020 04:55:40 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id oF1SBcwK4142PQAAB5/wlQ (envelope-from ) for ; Fri, 12 Jun 2020 04:55:40 +0000 Received: from pb-smtp1.pobox.com (pb-smtp1.pobox.com [64.147.108.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 181899403E9 for ; Fri, 12 Jun 2020 04:55:35 +0000 (UTC) Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 1D2146BB0F; Fri, 12 Jun 2020 00:55:34 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; s=sasl; bh=NQD2fVGWoxHBLuhhJW+lnFMBPuY=; b=a2EfBUOLO/lfkq5NGp7/ oQNgWhIz1zARueiawvDHMuhL/IyYhcscIgfNzD+ULbksgPWTMKA1fQTctEidwcwM C65hSmRHixAcHSvXMvybtdYh5Xws2XjksVA0ZZKbiUMNKVJs0GEbRFUWemwB8exf 4twxau0M04PHfI51KW8uzaI= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 161EA6BB0E; Fri, 12 Jun 2020 00:55:34 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:cc:subject:date:message-id:mime-version:content-transfer-encoding; s=mesmtp; bh=yy3dtDN2i7v5gytoCWJsth00MROJo6osfqdlBaFibrg=; b=0Kp/7DTY87GJqpe4a8MtcdmyWWvHHZycByx6ECkH6PtaaA6lwlGEErXSYEG9ch5Dm6i2ewExZQ93dYlFaqQsunOdeBCxfJXDaAXM9dhlTMEW5cmBZFU5/43VJclpr+PbxY9/PGnd8Y3at9e9OkA399OG4zuTEWXlITgpBEnRncI= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id 8283B6BB0D; Fri, 12 Jun 2020 00:55:33 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: piem@inbox.kyleam.com Cc: Kyle Meyer Subject: [PATCH] Support adding Message-Id to attached patches Date: Fri, 12 Jun 2020 00:55:23 -0400 Message-Id: <20200612045523.18120-1-kyle@kyleam.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Pobox-Relay-ID: F2A23BEC-AC68-11EA-A18A-C28CBED8090B-24757444!pb-smtp1.pobox.com Content-Transfer-Encoding: quoted-printable X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=pobox.com header.s=sasl header.b=a2EfBUOL; dkim=fail (body hash did not verify) header.d=kyleam.com header.s=mesmtp header.b=0Kp/7DTY; dmarc=none; spf=pass (aspmx1.migadu.com: domain of kyle@kyleam.com designates 64.147.108.70 as permitted sender) smtp.mailfrom=kyle@kyleam.com X-Spam-Score: 2.50 X-TUID: E5DFxW+WKrWo With an inline patch that has a Message-Id, this information can be linked up to the patch when applied (e.g., with git-am's --message-id flag or using a post-applypatch hook [1]). Unfortunately, this method fails for projects where it is common to attach patches, as there is no Message-Id within the patch. Teach piem-am-ready-mbox how to insert the Message-Id that piem-mid reports, which should always correspond to the message that contains the patch attachments. [1] Here's an example that used to keep the commit->Message-Id mapping in git.git: https://lore.kernel.org/git/xmqq7e5ag4g5.fsf@gitster-ct.c.googlers.co= m/ --- piem.el | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/piem.el b/piem.el index a757092..fcd5d8c 100644 --- a/piem.el +++ b/piem.el @@ -101,6 +101,14 @@ (defcustom piem-am-ready-mbox-functions nil arguments and inserts the mbox's contents in the current buffer." :type 'hook) =20 +(defcustom piem-add-message-id-header nil + "Whether to add Message-Id header to non-mail patches. +If this value is non-nil and a patch returned by a function in +`piem-am-ready-mbox-functions' looks like a patch that was +attached rather than sent inline, add a Message-Id header with +the value of `piem-mid'." + :type 'boolean) + (defcustom piem-git-executable (or (and (boundp 'magit-git-executable) magit-git-executable) "git") @@ -300,10 +308,19 @@ (defun piem-am-ready-mbox () (when-let ((fn (run-hook-with-args-until-success 'piem-am-ready-mbox-functions))) (let ((buffer (generate-new-buffer " *piem am-ready mbox*")) + (mid (and piem-add-message-id-header (piem-mid))) has-content) (with-current-buffer buffer (funcall fn) - (setq has-content (< 1 (point-max)))) + (setq has-content (< 1 (point-max))) + (when (and has-content mid) + (goto-char (point-min)) + (while (re-search-forward + (rx "From " (>=3D 40 hex-digit) " Mon Sep 17 00:00:00 = 2001") + nil t) + (search-forward "\n\n") + (forward-line -1) + (insert (format "Message-Id: <%s>\n" mid))))) (if has-content buffer (kill-buffer buffer) base-commit: 54ea4ed7d1bc64222cf837ecc046f7aa4f42c769 --=20 2.26.2