The diff command, even using git option, includes path prefixes commonly used on DCS:
--- a/file.ext
+++ b/file.ext
So applying such patches you should need to using -p1 instead of -p0.
Is there any way to generate clean patched from Mercurial?
Mercurial 不会发出 -p0 补丁。正如@Ringdig 指出的那样,它们很少是您想要的。
您可以调整此答案中给出的查看脚本:转换补丁条级别以删除第一个目录而不是添加它。
像这样的东西应该可以工作(未经测试):
sed \
-e 's!^--- a/!--- !' \
-e 's!^+++ b/!+++ !' \
< p1.patch \
> p0.patch
假设您的“p1 补丁”在名为 p1.patch 的文件中,则输出将在 p0.patch 中