diff/patch

OMG that seemed to be overly difficult. All I wanted to do was create a patch of a duplicate local folder and apply it locally to the folder in the svn repository. I kept getting the problem that `patch` only wanted to apply the patchfile in the wrong directory.
After a long time in `#svn` the answer was to use relative `diff` and `patch` commands.
1. `cd` into the directory that contains the 2 directories you’re messing with.
In my case this was altering themes in [Squib][1]. So starting in `squib/trunk` the command was
`cd ./themes`
2. Run the `diff` on relative paths. In this case `folder1` has the changes and `folder2` contains the files to be changed.
`diff -r -u -x “.*” folder2 folder1 > patchfile`
3. `cd ./folder2`
4. Apply the patch.
`patch -p1 < ../patchfile`
For some reason beyond my explanation when I was using absolute paths the patch kept wanting to be applied in reverse. Curious.
[1]:http://squib.rubyforge.org/

Filed under: Uncategorized