How to apply a diff file for a folder, using patch, on a different folder when full path is present?
Pass -p
followed by the appropriate number of path prefixes to strip.
Dan Nissenbaum
Freelance C++ and PHP developer, with PhD in physics, in Brattleboro, VT, USA Generally with bare feet Best to all!
Updated on July 13, 2022Comments
-
Dan Nissenbaum almost 2 years
I have downloaded a diff file to modify a number of files within a versioned project directory (Xerces 2.8). The diff file contains the full path for each "left" file (the one represented by the - signs). The "right" file (+ signs) contains a relative path. For example:
--- /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_textproc_xercesc/work/xerces-c-src_2_8_0/src/xercesc/util/Platforms/MacOS/MacCarbonFile.cpp 2007-08-28 20:44:07.000000000 +0200 +++ src/xercesc/util/Platforms/MacOS/MacCarbonFile.cpp 2009-10-28 19:37:22.000000000 +0100
My local copy of the project directory that I'd like to update with the diff file is, of course, at a different full path.
I cannot figure out where to place the diff file (or rather, in what directory to position myself when I run
patch
) and what command to run.Because the second (+) file is a relative path, I thought that positioning myself in the proper location in my local file system so that the relative path is correct - and then issuing the command
patch -i patchfile
... would work. It does not (instead,
patch
presents me with a prompt for each file because it cannot locate it).What command should I issue to get the diff file to merge using
patch
?