1

I've been banging my head on this one all day, and can't solve it.

I'm trying to patch a file with a generated diff file, where the diff file was generated from two different locations. The destination file location is also different.

The locations are

source: /home/paul/M/C/D/Android.mk
reference: /home/paul/A/B/C/D/Android.mk
destination: /home/paul/X/Y/Z/C/D/Android.mk

and I want to get the diffs between the source and reference, and apply them as as a patch to the destination. The patch was generated as follows

cd /home/paul/M
diff -u C/D/Android.mk  /home/A/B/C/D/Android.mk >> C/patch.diff

The patch file contains

--- C/D/Android.mk        2016-01-13 12:37:18.896126389 +0100
+++ /home/paul/A/B/C/D/Android.mk   2015-09-24 12:13:38.749361238 +0200
<differences>

I copy the patch file to a third location and apply the patch

cp C/patch.diff ~/X/Y/Z/C/.
cd ~/X/Y/Z
patch -p1 --dry-run -d C < C/auro_patch.diff

can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|*** C/D/Android.mk       2016-01-13 12:37:18.896126389 +0100
|--- /home/paul/A/B/C/D/Android.mk        2015-09-24 12:13:38.749361238 +0200

I think the problem is that patch is looking for the source file /home/paul/A/B/C/D/Android.mk. The error message is also strange because it refers to line 3, which has no file location information. Even stranger, why does patch even need the location of the original file? I thought it should simple modify the destination file with the patch details, no?

I've been playing with -p option, but I have the impression that patch expects the source and destination to have the same directory depth. The project hierarchy C/D is the same for all three project locations. However, the parent root directory is different in each case.

Can anyone help? I can 't used "git apply" unfortunately, which would be much easier.

Thanks, Paul

Paul
  • 443
  • 8
  • 18

1 Answers1

0

I solved it by specifying the full paths for the source, destination and patch files

Paul
  • 443
  • 8
  • 18