When running git-am to apply a patch series I had saved into an mbox file from a mailing list, if the mbox also contains the cover letter (otherwise known as PATCH [0/N]), it complains as follows:
128 git … am --3way ~/patches/sample.mbox
Patch is empty.
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
It is true the cover letter is an empty patch as there isn't a patch delimiter contained within, but I would've thought git am
would be smart enough to notice it and skip it altogether. This is not a major nuisance as I can skip adding this patch into the mbox from mutt without trouble, but sometimes a patch series arrives to the mailing list somewhat scrambled, and I can't just copy the entire thread into the same mbox.
Alternatively I can manually skip the patch and it will apply smoothly.
Is there any way I can instruct git am to skip patch number 0 when it is indeed a cover letter?
With Git 2.35 (Q1 2022), "
git am
"(man) learns--empty=(stop|drop|keep)"
and--allow-empty
options to tweak what is done to a piece of e-mail without a patch in it.So try again (Git 2.35+) with:
See commit 9e7e41b, commit 7c096b8, commit 552038e (09 Dec 2021) by 徐沛文 (Aleen) (
aleen42
).(Merged by Junio C Hamano --
gitster
-- in commit ead6767, 05 Jan 2022)git am
now includes in its man page: