本文介绍了转换补丁条级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个可以用-p0 应用的补丁,是否有工具可以自动将这个补丁转换为-p1 补丁.例如,变换
Suppose I have a patch that can be applied with -p0, is there a tool to automatically transform this patch into a -p1 patch. For example, transforming
Index: stdio-common/_i18n_number.h
===================================================================
--- stdio-common/_i18n_number.h (revision 8348)
+++ stdio-common/_i18n_number.h (working copy)
@@ -116,7 +116,7 @@ _i18n_number_rewrite (CHAR_T *w, CHAR_T
#else
static CHAR_T *
-_i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr)
+_i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr, CHAR_T *end)
{
return w;
}
进入同一个补丁但目录名不同(注意路径前面的a、b)
Into the same patch but with different directory name (notice the a, b) in front of the path
Index: stdio-common/_i18n_number.h
===================================================================
--- a/stdio-common/_i18n_number.h (revision 8348)
+++ b/stdio-common/_i18n_number.h (working copy)
@@ -116,7 +116,7 @@ _i18n_number_rewrite (CHAR_T *w, CHAR_T
#else
static CHAR_T *
-_i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr)
+_i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr, CHAR_T *end)
{
return w;
}
推荐答案
简单地转换 diff 块头中的文件名就足够了.
Simply transforming the filenames in the diff chunk headers is good enough.
sed \
-e 's!^--- !&a/!' \
-e 's!^+++ !&b/!' \
< p0.patch \
> p1.patch
对于其他补丁修改工具,我建议使用 patchutils,但这个很简单没有预先存在的实用程序.
For other patch mangling tools, I'd suggest patchutils, but this one is so simple that there's no pre-existing utility for it.
这篇关于转换补丁条级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!