From: Alejandro Colomar <alx@kernel.org>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: git-send-email: Send with mutt(1)
Date: Wed, 8 Nov 2023 22:02:52 +0100 [thread overview]
Message-ID: <ZUv3gjjmuqvCaJEd@debian> (raw)
In-Reply-To: <20231107201655.GA507701@coredump.intra.peff.net>
[-- Attachment #1: Type: text/plain, Size: 4632 bytes --]
Hi Jeff!
On Tue, Nov 07, 2023 at 03:16:55PM -0500, Jeff King wrote:
> > I had been thinking these days that it would be useful to have
> > format-patch generate those. How about adding a --signed-off-by-cc to
> > format-patch?
>
> That seems like a reasonable feature. Probably it should be
> --cc-from-trailer=signed-off-by, and then you could do the same with
> other trailers.
That would work for me. I only suggested the other one because it's
aleady in send-email in that form. But yeah, it might be useful to have
finer control. In my case, something that CCs every mail in the trailer
would work (Reviewed-by, Suggested-by, ... I want them all, always).
>
> It feels like you could _almost_ do it with the existing
> --format='%(trailers)' functionality, but there's no way to say "do the
> regular --format=email output, but also stick this extra format in the
> headers section". Plus there are probably some niceties you'd get from
> Git knowing that you're adding headers (like de-duping addresses).
>
> That feature might end up somewhat hairy, though, as then you get into
> questions of parsing address lists, etc. We do all that now in perl with
> send-email, where we can lean on some parsing libraries. So I dunno.
Hmmm.
>
> > > If you're sending a long series, it's helpful to pre-populate various
> > > headers in the format-patch command with "--to", etc. I usually do so by
> > > sending the cover letter directly via mutt, and then using some perl
> > > hackery to convert those headers into format-patch args. The script I
> >
> > Indeed, that hackery is what send-email already does, so how about
> > moving those features a bit upstream so that format-patch can do them
> > too?
>
> Yeah, if they existed in format-patch I might be able to reuse them. I
> am hesitant, though, just because handling all the corner cases on
> parsing is going to be a bit of new C code.
>
> > Although then, maybe it's simpler to teach send-email to learn to use
> > mutt(1) under the hood for the actual send.
>
> I think you will find some corner cases in trying to make mutt act just
> like an mta accepting delivery. Two I can think of:
>
> 1. It will take a body on stdin, but not a whole message. We can hack
> around that with some postponed-folder magic, though.
>
> 2. Bcc headers are stripped before sendmail sees the message (but
> those addresses appear on the command-line). Converting that back
> to bcc so that mutt can then re-strip them would be annoying but
> possible. If you don't use bcc, it probably makes sense to just
> punt on this.
Meh, I can live with no Bcc feature; I never used it before. :)
>
> So maybe a script like this:
>
> -- >8 --
> #!/bin/sh
>
> # ignore arguments; mutt will parse them itself
> # from to/cc headers. Note that we'll miss bcc this
> # way, but handling that would probably be kind of
> # tricky; we'd need to re-add those recipients as actual
> # bcc headers so that mutt knows how to handle them.
>
> # spool the message to a fake mbox; we need to add
> # a "From" line to make it look legit
> trap 'rm -f to-send' 0 &&
> {
> echo "From whatever Mon Sep 17 00:00:00 2001" &&
> cat
> } >to-send &&
Would a named pipe work? Or maybe we could use $(mktemp)?
>
> # and then have mutt "resume" it. We have to redirect
> # stdin back from the terminal, since ours is a pipe
> # with the message contents.
> mutt -p \
> -e 'set postponed=to-send' \
> -e 'set edit_headers=yes' \
> </dev/tty
> -- 8< --
Huh, this is magic sauce! Works perfect for what I need. This would
need to be packaged to the masses. :-)
I found a minor problem: If I ctrl+C within mutt(1), I expect it to
cancel the last action, but this script intercepts the signal and exits.
We would probably need to ignore SIGINT from mutt-as-mta.
Other than that, this fulfills all of my needs.
Would you mind adding this as part of git? Or should we suggest the
mutt project adding this script?
Thanks a lot!
Cheers,
Alex
>
> and then in your git config:
>
> [sendemail]
> sendmailcmd = /path/to/mutt-as-mta.sh
>
> There are mutt-specific bits there that I don't think send-email should
> have to know about. Perhaps there are generic options that send-email
> could learn, but it really feels like you'd do better teaching mutt to
> be more ready to handle this (like taking a whole message on stdin,
> headers and all, rather than just a body).
>
> -Peff
--
<https://www.alejandro-colomar.es/>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-11-08 21:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-07 11:14 git-send-email: Send with mutt(1) Alejandro Colomar
2023-11-07 17:48 ` Jeff King
2023-11-07 18:36 ` Alejandro Colomar
2023-11-07 20:16 ` Jeff King
2023-11-08 21:02 ` Alejandro Colomar [this message]
2023-11-08 21:27 ` Jeff King
2023-11-09 15:26 ` Alejandro Colomar
2023-11-09 16:08 ` Konstantin Ryabitsev
2023-11-09 17:42 ` Alejandro Colomar
2023-11-09 17:59 ` Konstantin Ryabitsev
2023-11-10 21:06 ` Alejandro Colomar
2023-11-09 18:03 ` Jeff King
2023-11-09 23:00 ` Alejandro Colomar
2023-11-10 0:51 ` Alejandro Colomar
2023-11-10 13:30 ` Alejandro Colomar
2023-11-10 21:41 ` Jeff King
2023-11-10 23:31 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZUv3gjjmuqvCaJEd@debian \
--to=alx@kernel.org \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).