[CentOS] patching from different directory

Thu Sep 10 18:28:02 UTC 2009
Carlos Santana <neubyr at gmail.com>

Thanks Filipe.

I can do it by cd-ing into file-to-be-patched dir. I think the -d
switch in patch command does similar thing (cd). But then it assumes
diff file also to be present in that new directory.

I guess the problem is not having full dir path in the diff file
itself. The diff file mentions only file name. How do I get full path
in my diff file? Any clues?

-
CS.


On Thu, Sep 10, 2009 at 1:12 PM, Filipe Brandenburger
<filbranden at gmail.com> wrote:
> Hi,
>
> On Thu, Sep 10, 2009 at 14:04, Carlos Santana <neubyr at gmail.com> wrote:
>> I have a diff file in my /var/tmp and would like to apply patch to a
>> file in a different directory (other than /va/tmp). I tried using
>> patch with -d switch, but that doesn't work. It complains abt  'patch:
>> **** Can't open patch file tilda.diff : No such file or directory'. Do
>> I need to copy my diff file to the directory where original file
>> resides? Or is there any other way round?
>
> Try:
>
> cd /path/to/file/to/be/patched
> patch -p0 </var/tmp/tilda.diff
>
> You might want to use -p1 or -p2 or -p3... depending on what is the
> path to the file inside the .diff file. To figure that out, open the
> .diff file and look at the lines that start with --- and +++, then see
> how many directories are there before the filename, use that number
> for the argument to -p.
>
> HTH,
> Filipe
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos
>