in reply to How to apply a patch on Windows?

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)
$ 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 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 -ruN old/f1 new/f1 |--- old/f1 2010-04-22 23:57:33.843750000 -0700 |+++ new/f1 2010-04-22 23:57:33.859375000 -0700 -------------------------- File to patch: patch -p1 -dold1 < temp.patch patch: No such file or directory Skip this patch? [y] Skipping patch. 1 out of 1 hunk ignored $ cd old2 $ patch < ../temp.patch patching file f1 $ cd ../old3 $ patch -p0 < ../temp.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 -ruN old/f1 new/f1 |--- old/f1 2010-04-22 23:57:33.843750000 -0700 |+++ new/f1 2010-04-22 23:57:33.859375000 -0700 -------------------------- File to patch: patch -p1 < ../temp.patch patch: No such file or directory Skip this patch? [y] Skipping patch. 1 out of 1 hunk ignored $ cd .. $ cat old\f1 ECHO is on. $ cat old1\f1 ECHO is on. $ cat old2\f1 ECHO is on. ECHO is on. $ cat old3\f1 ECHO is on. $ cat new\f1 ECHO is on. ECHO is on. $ cat temp.patch diff -ruN old/f1 new/f1 --- old/f1 2010-04-22 23:57:33.843750000 -0700 +++ new/f1 2010-04-22 23:57:33.859375000 -0700 @@ -1 +1,2 @@ ECHO is on. +ECHO is on. $ cd .. $ rm -rf tmp $ sscite snap.bat $ pwd D:\tmp $ call snap.bat $ md tmp $ cd tmp $ md old $ md old1 $ md old2 $ md old3 $ md new $ echo 1>old/f1 $ echo 1>old1/f1 $ echo 1>old2/f1 $ echo 1>old3/f1 $ echo 1>new/f1 $ echo 1>>new/f1 $ diff -ruN old new 1>temp.patch $ patch -p0 -dold1 0<temp.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 -ruN old/f1 new/f1 |--- old/f1 2010-04-22 23:59:47.968750000 -0700 |+++ new/f1 2010-04-22 23:59:47.968750000 -0700 -------------------------- File to patch: Skip this patch? [y] Skipping patch. 1 out of 1 hunk ignored $ patch -p1 -dold1 0<temp.patch patching file f1 $ cd old2 $ patch 0<../temp.patch patching file f1 $ cd ../old3 $ patch -p0 0<../temp.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 -ruN old/f1 new/f1 |--- old/f1 2010-04-22 23:59:47.968750000 -0700 |+++ new/f1 2010-04-22 23:59:47.968750000 -0700 -------------------------- File to patch: Skip this patch? [y] Skipping patch. 1 out of 1 hunk ignored $ patch -p1 0<../temp.patch patching file f1 $ cd .. $ cat old/f1 ECHO is on. $ cat old1/f1 ECHO is on. ECHO is on. $ cat old2/f1 ECHO is on. ECHO is on. $ cat old3/f1 ECHO is on. ECHO is on. $ cat new/f1 ECHO is on. ECHO is on. $ cat temp.patch diff -ruN old/f1 new/f1 --- old/f1 2010-04-22 23:59:47.968750000 -0700 +++ new/f1 2010-04-22 23:59:47.968750000 -0700 @@ -1 +1,2 @@ ECHO is on. +ECHO is on. $

Replies are listed 'Best First'.
Re^2: How to apply a patch on Windows?
by BrowserUk (Patriarch) on Apr 23, 2010 at 07:17 UTC

    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.

        Why exactly?

        Because without a clue about what I'm meant to be looking for, in that volume of very similar looking lines, it is really hard to pick out the significant bit, -p0 .v. -p1, before my eyes glaze over.

        So mnooning needs to change ...

        Now that I follow. Succinct, clear and to the point.

        Thankyou. I learnt two things.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.