I have a reason¹ to create my git commits as patch files using git-format-patch with the --no-prefix option.
This option changes the patch output to not add the git-diff-specific prefixes a/ / b/ in file paths in the patch files. It allows tools like patch to apply the patch files without the need to pass -p1 as argument.
All cool so far. However, it seems that I cannot actually apply them anymore with Git itself (git-am):
$ git am path/to/0001-patch.patch
Applying: <commit message subject>
error: <path>: does not exist in index
Patch failed at 0001
[...]
How do I apply them with git-am now, while maintaining plain patch compatibility?
¹ It allows me to use it as patch files in Bazel without custom patch commands, as you'd need to apply patches with patch -p1 [...].
git-ampasses on a few options togit-apply, including the-poption, which does the same as it does withpatch. Ie., apply such patches with-p0:It would have been great if
git-format-patchwas able to hintgit-amwithin the auxiliary data of the patch file created, that it should apply them without the assumption of a path prefix — just like it can hintgit-amwith base tree information nowadays (see--baseoption).