[PATCH] aiaiai-email-lda: use the References mail header
Robert Jarzmik
robert.jarzmik at free.fr
Thu Nov 6 10:50:28 PST 2014
Aiaiai local mail delivery agent should be able to cope with forwarded
mails, not only git-send-email.
One popular method of forwarding a mail thread is to have it embedded in
a single mulitpart mail in rfc822 format. But this transformation
changes the In-Reply-To: headers into References: headers.
The goal of this patch is to teach aiaiai LDA to understand both
In-Reply-To and References in its mail handling. This enables mail
forwarding.
Signed-off-by: Robert Jarzmik <robert.jarzmik at free.fr>
---
doc/README | 22 ++++++++++++++++++++++
email/aiaiai-email-lda | 13 ++++++++-----
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/doc/README b/doc/README
index 0e699a2..0e6571c 100644
--- a/doc/README
+++ b/doc/README
@@ -102,6 +102,28 @@ The 'aiaiai-test-patchset' script does all the testing work and outputs the
test results to stdout. 'aiaiai-email-test-patchset' captures the output and
sends it back to the patch submitter.
+A more complicated mail setup dealing with forwards and multi-part emails
+would be :
+$ cat /home/aiaiai/bin/my-aiaiai-lda
+ #!/bin/sh
+ formail_opt=""
+
+ mail=$(mktemp)
+ cat > $mail
+
+ to="$(formail -c -z -x "To:" < $mail)"
+ [ -n "$to" ] && formail_opt="$formail_opt -I \"To: $to\""
+
+ project="$(formail -c -z -x "X-Aiaiai-Project:" < $mail)"
+ [ -n "$project" ] && formail_opt="$formail_opt -I \"X-Aiaiai-Project: $project\""
+
+ commit="$(formail -c -z -x "X-Aiaiai-Commit:" < $mail)"
+ [ -n "$commit" ] && formail_opt="$formail_opt -I \"X-Aiaiai-Commit: $commit\""
+
+ cat "$mail" | eval formail $formail_opt -d -s $HOME/git/email/aiaiai-email-lda \
+ -v --reap-archive=43200 --reap-incomplete=10 -- $HOME/aiaiai-workdir \
+ >> $HOME/aiaiai-logs/email-lda.log" 2>&1
+
1.2 Email Configuration
~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/email/aiaiai-email-lda b/email/aiaiai-email-lda
index 365d7cf..b3e78dd 100755
--- a/email/aiaiai-email-lda
+++ b/email/aiaiai-email-lda
@@ -157,10 +157,10 @@ find_relatives()
local parent_id="$1"; shift
# Find the parent, children, and brothers
- LC_ALL=C grep -i -l -r -- "In-Reply-To: $id" "$where" ||:
+ LC_ALL=C grep -i -l -r -- "\(In-Reply-To\|References\): $id" "$where" ||:
if [ -n "$parent_id" ]; then
LC_ALL=C grep -i -l -r -- "Message-Id: $parent_id" "$where" ||:
- LC_ALL=C grep -i -l -r -- "In-Reply-To: $parent_id" "$where" ||:
+ LC_ALL=C grep -i -l -r -- "\(In-Reply-To\|References\): $parent_id" "$where" ||:
fi
}
@@ -173,6 +173,7 @@ series_is_complete()
local cnt="$(ls -1 --ignore=0 -- "$dir" | wc -l)"
if [ "$cnt" -eq "$n" ]; then
local first_parent="$(fetch_header "In-Reply-To" < "$dir/1")"
+ [ -z "$first_parent" ] && first_parent="$(fetch_header "References" < "$dir/1")"
if [ -n "$first_parent" ]; then
# The first patch has a parent, must be the cover letter
if [ -f "$dir/0" ]; then
@@ -258,7 +259,7 @@ move_to_series()
#
# The series is collected using message ID headers - each patch, except of may
# be the first one, must refer the previous patches ID via teh "In-Reply-To"
-# header.
+# header or "References" header.
process_series_mbox()
{
local mbox="$1"; shift
@@ -269,12 +270,14 @@ process_series_mbox()
# Only patch 0/n or 1/n is allowed to have no parent
local parent_id="$(fetch_header "In-Reply-To" < "$mbox")"
+ [ -z "$parent_id" ] && parent_id="$(fetch_header "References" < "$mbox")"
if [ -z "$parent_id" ] && [ "$m" != 1 ] && [ "$m" != 0 ]; then
reject_and_reply "$mbox" <<EOF
You sent a patch that does not conform to the requirements for Aiaiai's Local
Delivery Agent. This patch is part of a series as indicated by its subject
-prefix. However, it does not contain the correct "In-Reply-To:" header which
-is required for Aiaiai to determine which patch series it belongs with.
+prefix. However, it does not contain the correct "In-Reply-To:" header or
+"References" header which is required for Aiaiai to determine which patch
+series it belongs with.
The most common reason for this issue is from not using the git-send-email
utility, and using your own script which does not generate proper In-Reply-To:
--
2.1.0
More information about the aiaiai
mailing list