Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

How to apply a patch on Windows?

by mnooning (Sexton)
on Apr 23, 2010 at 00:27 UTC ( #836373=perlquestion: print w/ replies, xml ) Need Help??
mnooning has asked for the wisdom of the Perl Monks concerning the following question:

Someone sent in a patch for one of my modules. I want to apply the patch.
This did not work:
C:\temp>applypatch --verbose -dir Net-Daemon Net-Daemon-5.10-support.patch
Validate input.
Patch kit apparently okay.
Verify source directory.
Source directory apparently okay.

A diff -r in a cygwin window of a copy of the dir showed that there were no changes, and indeed
the ChangeLog for the module was unchanged.

Within my cygwin window, I tried patch as shown further below.
I started gettign a long series of questions, as you see.
Is this a bad patch, or am I doing something wrong?

$ patch -p0 -dNet-Daemon < Net-Daemon-5.10-support.patch
can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -ruad Net-Daemon/ChangeLog Net-Daemon-fixed/ChangeLog
|--- Net-Daemon/ChangeLog 2010-03-12 14:38:33.000000000 -0800
|+++ Net-Daemon-fixed/ChangeLog 2010-03-12 14:45:56.000000000 -0800
--------------------------
File to patch:

Comment on How to apply a patch on Windows?
Re: How to apply a patch on Windows?
by Anonymous Monk on Apr 23, 2010 at 07:00 UTC
    Is this a bad patch, or am I doing something wrong?

    Patch tells you exactly what you're doing wrong.

    Here is a short patch tutorial for you in the form of a shell/batch file

    md tmp cd tmp md old md old1 md old2 md old3 md new echo >old/f1 echo >old1/f1 echo >old2/f1 echo >old3/f1 echo >new/f1 echo >>new/f1 diff -ruN old new >temp.patch patch -p0 -dold1 < temp.patch patch -p1 -dold1 < temp.patch cd old2 patch < ../temp.patch cd ../old3 patch -p0 < ../temp.patch patch -p1 < ../temp.patch cd .. cat old/f1 cat old1/f1 cat old2/f1 cat old3/f1 cat new/f1 cat temp.patch
    Here is the output of the run (notice the same error message)

      Maybe there's a clue to the solution to the OPs problem in there somewhere, but if there is, it went right over my head.

        Maybe there's a clue to the solution to the OPs problem in there somewhere, but if there is, it went right over my head.

        Why exactly? I see I posted erroneously extra output, but if you run the batch file, you should be able to follow and learn how patch processes files.

        Its a basic path management problem.

        mnooning specifies -p0 -dNet-Daemon which means cd to Net-Deamon and strip zero leading path parts, so patch looks for Net-Daemon/ChangeLog in Net-Deamon (Net-Deamon/Net-Deamon/ChangeLog) which doesn't exist.

        So mnooning needs to change to -p1, or remove both -p/-d options... or manually enter the correct file path when prompted.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://836373]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2014-07-13 03:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (245 votes), past polls