[Linux-disciples] patch(1)

Adam Rosi-Kessel adam at rosi-kessel.org
Wed Jul 5 10:49:45 EDT 2006


Stephen R Laniel wrote:
> On Thu, Jun 29, 2006 at 09:40:08AM -0400, Adam Rosi-Kessel wrote:
>> cd ~/code
>> diff -u -r old_version old_patched_version > p.diff
>> cd new_version
>> cat ../p.diff | patch -p1
> 
> That did the trick for me; thanks, Adam.
> 
> One little question: what if the directories that we're
> diffing have different numbers of slashes? How many slashes
> do we cut out with '-p'? I had five slashes in one of the
> paths and seven in the other, so I added a directory called
> 'foo/foo' to make the slashes line up. Is there a better
> way?

I can't fully parse your question as posed. Basically, you just need to
match the root for your diff to your new root. If you are doing a recursive
unified diff, everything in the old directory tree will start from the same
"top level" depth; you just need to match that depth to your new directory
tree. Unless you are trying to apply the patch to files that are laid out
differently, there shouldn't be any problem or need to create fake depth. If
you need to trim off more /'s from your diff file, just increase the -p
setting on patch to the correct number.


More information about the Linux-disciples mailing list