Ethereal-dev: Re: [Ethereal-dev] What's the recommended way to use the patch tool?
Ulf Lamping said:
> There are "usually" two pathnames in the patch, what does the patch tool
> do, if they have different "lengths", e.g.:
>
> diff -ur ../ethereal-0.10.6/epan/dissectors/packet-dcerpc.c
> ./epan/dissectors/packet-dcerpc.c
> --- ../ethereal-0.10.6/epan/dissectors/packet-dcerpc.c 2004-08-12
> 15:42:26.000000000 -0700
> +++ ./epan/dissectors/packet-dcerpc.c 2004-08-19 18:48:32.000000000
> -0700
>
> Will the patch tool use the shorter path (in this case the second one)?
I'm not sure *what* it'd do in that case; try it and see.
> missunderstanding: I meant in both cases one diff file containing one
> file with diffs in one case and multiple files with diffs in the other
> case. From the answer you gave I would guess that there is no difference
> on how to call the patch tool.
If it's one patch file in both cases, you'd run "patch" the same way in
both cases.
One other thing to note - "cvs diff" produces output that at least some
versions of "patch" can't handle; you'd get something such as
Index: missing/dlnames.c
===================================================================
RCS file: /tcpdump/master/tcpdump/missing/dlnames.c,v
retrieving revision 1.5
diff -c -r1.5 dlnames.c
*** missing/dlnames.c 18 Nov 2003 23:09:43 -0000 1.5
--- missing/dlnames.c 31 Aug 2004 21:45:16 -0000
***************
from "cvs diff -c", and something similar from "cvs diff -u", and "patch",
unfortunately, would use the "diff -c" or "diff -u" line and try to patch
"dlnames.c" in the directory you're in, rather than in the "missing"
subdirectory.
For "cvs diff -c" or "cvs diff -u" diffs, there's a Python script
"cvsdiff-fix.py" in the "tools" directory in the Ethereal source tree; it
will fix up those lines in "cvs diff" output. It reads its standard input
by default, or can be given a file name on the command line, and writes to
the standard output, so if you're typing at a command interpreter that
does piping, you could do something such as
python tools/cvsdiff.py patchfile | patch -p0 -
to use "patchfile". (You might be able to leave the "python" out of the
command line on many UN*Xes.)
"svn diff" doesn't produce a "diff -c" or "diff -u" line, so its output
doesn't have that problem. Regular "diff -c" or "diff -u" output also
shouldn't have that problem.