Skip to contentSkip to conversation

make 'b4 mbox' reorder headers so piping to 'git imap-send' works

b4 Philippe Blain 2 participants 3 messages Dec 21, 2020 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hi,

I'm using 'b4 mbox -o- <url> | git imap-send' to quickly import threads to my email account when I see an interesting thread that I'd like to reply to (I contribute to Git but I'm not subscribed to the Git mailing list).

This only works if the emails in the threads have the 'From', 'Date' and 'Subject' headers in exactly that order, because that order is hard-coded in 'git imap-send' [1]. I wrote a small script [2] that just reads the headers and reorders them accordingly but I'd like to just use 'b4 mbox' instead as it has more features. However I discovered that such reordering is not done by b4. For example, this fails as 'git imap-send' reports 'nothing to send':

b4 mbox -o- https://lore.kernel.org/git/op.0vvmwohypvqxoc@damia/T/#u | git imap-send

It would be nice if b4 would take care of the reordering.

Cheers,

Philippe.

[1] https://git-scm.com/docs/git-imap-send#_description
[2] https://gist.github.com/phil-blain/d350e91959efa6e7afce60e74bf7e4a8

#1 lore raw
Quoted 15 lines · Philippe Blain

Hi,

I'm using 'b4 mbox -o- <url> | git imap-send' to quickly import threads to my email account when I see an interesting thread that I'd like to reply to (I contribute to Git but I'm not subscribed to the Git mailing list).

This only works if the emails in the threads have the 'From', 'Date' and 'Subject' headers in exactly that order, because that order is hard-coded in 'git imap-send' [1]. I wrote a small script [2] that just reads the headers and reorders them accordingly but I'd like to just use 'b4 mbox' instead as it has more features. However I discovered that such reordering is not done by b4. For example, this fails as 'git imap-send' reports 'nothing to send':

Quoted 3 lines

b4 mbox -o- https://lore.kernel.org/git/op.0vvmwohypvqxoc@damia/T/#u | git imap-send

It would be nice if b4 would take care of the reordering.

I'm not sure that's a great solution, as you may be hitting other weird corner-cases with git-imap-send. I suggest using isync/mbsync for this purpose. I just added a tweak to b4 mbox that will recognize when -o receives a maildir, in which case instead of saving an .mbox file, it will add messages to the maildir instead, e.g.:

b4 mbox -o ~/Mail [msgid]

This will add all messages from the retrieved thread to the mail spool in ~/Mail (assuming it has the expected {new,cur,tmp} subdirs).

Regards,
-K

#3 lore raw
In reply to a message not in the archive
Quoted 4 lines · Konstantin Ryabitsev via linux.kernel.org

b4 mbox -o ~/Mail [msgid]

This will add all messages from the retrieved thread to the mail spool in ~/Mail (assuming it has the expected {new,cur,tmp} subdirs).

I just added a -f|--filter-dupes flag to "b4 mbox" that will check the existing maildir for existing duplicates before adding messages from the retrieved thread. This allows neat things like retrieving the rest of the thread directly from mutt. If you add the following to .muttrc:

macro index 4 "<pipe-message>~/bin/b4.sh mbox -f -o ~/Mail<return>"

(obviously, use something other than ~/Mail if it's not where your maildir is)

This lets you hit "4" in the index view to retrieve the rest of the thread for the message that is currently selected (or tagged). Handy for when you're cc'd in the middle of a discussion and want to grab everything else for context.

NOTE: -f requires iterating through the entire maildir to collect existing msgids, so it's not recommended for huge maildirs.

-K