Nicolas Morey-Chaisemartin <NMoreyChaisemartin@xxxxxxx> writes: > I would need to add "some" level of parsing to am.c to make sure > the patch content is just garbage and that there are no actual > hunks for that. > > I did not find any public API that would allow me to do that, > although apply_path/parse_chunk would fit the bill. Is that the > right way to approach this ? I do not think you would want this non-patch cruft seen at the apply layer at all. Reading a mailbox, with the help of mailsplit and mailinfo, and being the driver to create a series of commits is what "am" is about, and it would have to notice that the non-patch cruft at the beginning is not a patch at all and defer creation of an empty commit with that cover material at the end. For each of the other messages in the series that has patches, it will need to call apply to update the index and the working tree so that it can make a commit, but there is NO reason whatsoever to ask help from apply, whose sole purpose is to read a patch and make modifications to the index and the working tree, to handle the cover material.