如何读取补丁.rej文件
我在将补丁应用到源代码树时遇到问题,这不是常见的 -p
剥离问题。 patch
能够找到要修补的文件。
具体来说,我的问题是如何读取/解释 patch
在一些大块头失败时创建的 .rej
文件。我见过的大多数关于 patch
/diff
的讨论都不包括这一点。
I'm having trouble applying a patch to my source tree, and it's not the usual -p
stripping problem. patch
is able to find the file to patch.
Specifically, my question is how to read / interpret the .rej
files patch
creates when it fails on a few hunks. Most discussions of patch
/diff
I have seen don't include this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一个简单的例子:
如您所见:旧文件包含第 2 行,新文件应该包含第 b 行。但是,它实际上包含 c 行(在拒绝文件中不可见)。
事实上,解决此类问题最简单的方法是从 .diff/.patch 文件中取出 diff 片段,将其插入到要修补的文件中的适当位置,然后手动比较代码以找出哪些行实际上引发了冲突。
或者 - 或者:获取原始文件(未修改),对其进行修补并对文件运行三向合并。
A simple example:
As you can see: The old file contains line 2 and the new file should contain line b. However, it actually contains line c (that's not visible in the reject file).
In fact, the easiest way to resolve such problems is to take the diff fragment from the .diff/.patch file, insert it at the appropriate place in the file to be patched and then compare the code by hand to figure out, what lines actually cause the conflict.
Or - alternatively: Get the original file (unmodified), patch it and run a three way merge on the file.
Wiggle 是一个在补丁不成功时应用 .rej 文件的好工具。
Wiggle is a great tool for applying .rej files when patch does not succeed.
我不是处理补丁文件的专家,但我想根据我对补丁文件所包含信息的理解,澄清如何阅读它们。
您的
.rej
文件将告诉您:在该文件中;
因此,给出这条消息,在我的 .rej 文件的开头注明:
diff a/www/js/app.js b/www/js/app.js (被拒绝的帅哥)
@@ -4,12 +4,24 @@
我发现对于我的问题文件 (
www/js/app
),原始文件(记为a /www/js/app.js
在第一行)和 .rej 文件(标记为b/www/js/
)从原始文件的第 4 行开始,然后继续12 行(第二行@@ -4,12, +4,24 @@
中逗号之前的部分),从新版本文件的第 4 行开始,然后继续24行(@@ -4,12, +4,24 @@
中逗号后面的部分。有关更多信息,请参阅补丁文件的优秀概述(包含我上面注释的信息,如以及有关添加的行和/或文件版本之间的详细信息)位于 http://blog.humphd.org/ 。
当然,欢迎任何更正或澄清
I'm not an expert on dealing with patch files, but I'd like to add some clarity on how to read them based on my understanding of the information they contain.
Your
.rej
files will tell you:for in that file;
So given this message, noted in the beginning of my .rej file:
diff a/www/js/app.js b/www/js/app.js (rejected hunks)
@@ -4,12 +4,24 @@
I see that for my problem file (
www/js/app
), the difference between the original (noted asa/www/js/app.js
on the first line) and the .rej file (noted asb/www/js/
) starts on line 4 of the original and goes on for 12 lines (the part before the comma in@@ -4,12, +4,24 @@
on line two), and starts on line 4 of the new version of the file and goes on for 24 lines (the part after the comma in@@ -4,12, +4,24 @@
.For further information, see the excellent overview of patch files (containing the information I note above, as well as details on lines added and/or between file versions) at http://blog.humphd.org/vocamus-906/.
Any corrections or clarifications welcome of course.