4

假设我有一个可以与 -p0 一起应用的补丁,是否有工具可以自动将此补丁转换为 -p1 补丁。例如,变换

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)

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;
 }
4

1 回答 1

3

只需转换 diff 块标头中的文件名就足够了。

sed \
    -e 's!^--- !&a/!' \
    -e 's!^+++ !&b/!' \
    < p0.patch \
    > p1.patch

对于其他补丁修改工具,我建议使用patchutils,但这个工具非常简单,没有预先存在的实用程序。

于 2009-06-17T14:23:32.563 回答