如何读取.rej文件,即 [英] How to read .rej files, i.e

查看:496
本文介绍了如何读取.rej文件,即的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在源代码树上应用补丁,这不是常见的 -p 剥离问题。 补丁能够找到要补丁的文件。

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.

具体来说,我的问题是如何读取/解释 .rej 文件补丁在文件出现故障时创建。我见过的大多数补丁 / diff 的讨论都不包含此内容。

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.

推荐答案

一个简单的例子:

$ echo -e "line 1\nline 2\nline 3" > a
$ sed -e 's/2/b/' <a >b
$ sed -e 's/2/c/' <a >c
$ diff a b > ab.diff
$ patch c < ab.diff
$ cat c.rej
***************
*** 2
- line 2
--- 2 -----
+ line b

如您所见:旧文件包含第2行,新文件包含b行。但是,它实际上包含第c行(在拒绝文件中不可见)。

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).

实际上,解决此类问题的最简单方法是从.diff / .patch文件,将其插入要修补的文件中的适当位置,然后手动比较代码以找出导致冲突的实际行。

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.

这篇关于如何读取.rej文件,即的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆