tags:

views:

1043

answers:

1

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.

+5  A: 

A simple example:

$ 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

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.

Regards, Bodo

bothie
simple and clear. thanks Bodo for the explanation, I a think getting the original file, and doing a 3-way merge will be the quickest for me.
I'm new to this site -- not sure how i can give 'points' for this answer. Keeps asking me for an openid