仅在不破坏任何内容的情况下应用补丁
Apply a patch only if it doesn't break anything
仅当干运行选项没有return错误时,我才尝试应用大量补丁。
但目前我只能尝试或应用所有补丁:
for i in /home/me/patch/*.patch; do patch -Np1 -f --dry-run < $i; done
因此不应应用生成 "hunk FAILED" 的补丁。
如果有人有想法。谢谢
尝试以下 grep 方法:
for i in /home/me/patch/*.patch; do
if ! grep -q 'hunk FAILED' <(patch -Np1 -f --dry-run < $i); then
patch -Np1 -f < $i
fi
done
或验证 patch
退出状态(使用 -s
(--silent
) 选项):
for i in /home/me/patch/*.patch; do
if patch -Np1 -f -s --dry-run < $i; then
patch -Np1 -f < $i
fi
done
仅当干运行选项没有return错误时,我才尝试应用大量补丁。
但目前我只能尝试或应用所有补丁:
for i in /home/me/patch/*.patch; do patch -Np1 -f --dry-run < $i; done
因此不应应用生成 "hunk FAILED" 的补丁。
如果有人有想法。谢谢
尝试以下 grep 方法:
for i in /home/me/patch/*.patch; do
if ! grep -q 'hunk FAILED' <(patch -Np1 -f --dry-run < $i); then
patch -Np1 -f < $i
fi
done
或验证 patch
退出状态(使用 -s
(--silent
) 选项):
for i in /home/me/patch/*.patch; do
if patch -Np1 -f -s --dry-run < $i; then
patch -Np1 -f < $i
fi
done