summaryrefslogtreecommitdiffstatshomepage
path: root/content/9/index.md
blob: f22ed612cb65397836ed350feafdc1ad4a58dada (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
+++
date = 2021-07-25T16:58:29+02:00
title = "git-am(1) and mail sorting"

[taxonomies]
tags = ["git", "TIL"]

[extra]
mentions = [8]
+++

In the {{ ref(id=8, text="previous post") }} I talked about a couple of
different ways to apply patches with `mutt(1)` or `neomutt(1)`. Turns out
`Maildir` might not be the best format to use for `git-am(1)` because its
files are not guaranteed to be in any specific order (per
[spec](https://cr.yp.to/proto/maildir.html) they need only carry unique names).

As `git-am(1)` does not sort its input, patches might be applied in the wrong
order. This came up on the mailing list as well, all the way
[back in 2013](https://public-inbox.org/git/20130301222018.GA839@WST420/).
A fix specific to `Maildir` files created by `mutt(1)` was added in
[`18505c3`](https://github.com/git/git/commit/18505c34237d3544729c3deed3e4f851fb672086).

Sadly `neomutt(1)` changed this format 5 years ago, removing the sequence number
that `git-am(1)` relies on in commit
[`75b3708`](https://github.com/neomutt/neomutt/commit/75b3708edb18815935692c60bbae56d5301f8210#diff-8904141e55cf466b09a2db0df752f92a29daf093e79df61121ecd347b7631c19L1489-L1491)
and replacing it with a call to `mutt_rand64()`. I can only assume no one is
using `neomutt(1)` to export patches to `Maildir`, since having patches applied
in the wrong order is a pretty significant problem.

For now I recommend using the `mbox` format instead when exporting patches.
Whilst that doesn't guarantee a specific order either, usually mail clients are
nice enough to export mails to `mbox` in the order they are shown.

The core issue remains until `git-am(1)` learns to sort mails itself.