[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: diff/patch with subdirectories
From: |
Glynn Clements |
Subject: |
Re: diff/patch with subdirectories |
Date: |
Mon, 05 Jul 2004 01:22:21 GMT |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Security Through Obscurity) |
Guy Rouillier <guy-rouillier@speakeasy.net> writes:
> >> --- from/aaa 2004-06-13 00:27:54.349910512 -0400
> >> +++ to/aaa 2004-06-13 00:28:15.889635976 -0400
> >> @@ -1 +1 @@
> >> -abc
> >> +def
> >>
> >> Now running patch produces this:
> >>
> >> patch -u -p0 <sub.diff
> >> patching file to/aaa
> >> Reversed (or previously applied) patch detected! Assume -R? [n]
> >
> > Use "patch -p1 < patchfile" to strip off the top-level of the path.
> >
> > At a later stage, if you're generating a patch for a whole directory
> > tree, "diff -urN" usually does the right thing.
>
> Roger, thank you for the reply. I've been away on business and I'm just
> getting caught up - I apologize for not responding more promptly.
>
> With the same set of sample inputs, I ran "diff -urN from to >subdir.diff"
> and it produced the following:
>
> diff -urN from/aaa to/aaa
> --- from/aaa 2004-06-13 00:27:54.000000000 -0400
> +++ to/aaa 2004-06-13 00:28:15.000000000 -0400
> @@ -1 +1 @@
> -111
> +222
>
> When I attempted to run patch, I got the following:
>
> /home/guyr>patch -p1 <subdir.diff
> 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 -urN from/aaa to/aaa
> |--- from/aaa 2004-06-13 00:27:54.000000000 -0400
> |+++ to/aaa 2004-06-13 00:28:15.000000000 -0400
> --------------------------
> File to patch:
>
> I'm obviously missing something very fundamental.
With "-p1", you have to "cd" into the directory (in this case, the one
which contains the "aaa" file).
OTOH, with "-p0", the directory has to have the same name as one of
the directories did when patch was run (in this case, "from" or "to").
The usual mechanism is to make the patch from the directory above the
top-level directory of the source trees. E.g. if you were making a
patch for the linux kernel, with source code in /usr/src/linux.orig
and /usr/src/linux.new, you would run "diff -ruN linux.orig linux.new"
from /usr/src. The pathnames would look like:
--- linux.orig/Documentation/Configure.help 2004-06-13
00:27:54.000000000 -0400
+++ linux.new/Documentation/Configure.help 2004-06-13
00:28:15.000000000 -0400
The patch would then be applied with -p1 from within the top-level
directory of the source tree, e.g.:
cd /usr/src/linux
patch -p1 < /path/to/linux.diff
The -p1 switch strips of one level of directories, so the above
section would patch the file Documentation/Configure.help relative to
the current directory (/usr/src/linux).
--
Glynn Clements <glynn.clements@virgin.net>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: diff/patch with subdirectories,
Glynn Clements <=