A source code tree contains a modified dnsmasq-2.80test4 source (and git files).
Now I'd like to apply the newest 2.86 dnsmasq source code to that modified 2.80test4 using diff and patch, while working in the users home folder.
So I start copying .../dnsmasq-2.80test4 to the users home dir, and create the diff file using:
~$ diff -urN ./dnsmasq-2.80test4 ./dnsmasq-2.86 > dnsmasq-2.86.diff
Then I'm trying to patch the old ~/dnsmasq-2.80test4 folder using:
~$ cd ./dnsmasq-2.80test4
~$ patch --dry-run -i ../dnsmasq-2.86.diff
which runs ok for CHANGELOG, FAQ, Makefile and Version. First file Android.mk in subdir bld fails, which is not a big deal. The real deal breaker is the second file in the same subdir:
can't find file to patch at input line 466
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff -ur ./dnsmasq-2.80test4/bld/get-version ./dnsmasq-2.86/bld/get-version
|--- ./dnsmasq-2.80test4/bld/get-version 2022-07-03 17:32:08.541879257 +0200
|+++ ./dnsmasq-2.86/bld/get-version 2021-09-08 22:21:22.000000000 +0200
--------------------------
Workaround
When changing the working directory to one level up and renaming the newer /dnsmasq-2.86 source directory to a different name (or just removing it), the patch seems to be correctly applied to the old /dnsmasq-2.80test4 dir using:
~$ patch --dry-run --verbose -p0 -i dnsmasq-2.86.diff
Question
How to modify the diff and/or patch commands, allowing me to patch from within the directory that needs to changed (cd ./parent/dnsmasq-2.80test4) as working directory, instead of working from cd ./parent dir?
gitwould make things easier to manage (have your custom changes in branch off the 2.80test4 tag, rebase them onto 2.86, resolve conflicts, etc).