Rockbox Development > Starting Development and Compiling
Problem applying patches
(1/1)
krawatte33:
I always get the message: "Can't find file to patch" when trying to patch something. If I type the filename manually it works. I used the VMWare image, downloaded the newest svn and try to apply a patch. This is what I get:
patch < additional_regions.patch
can't find file to patch at input line 5
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|Index: apps/recorder/radio.c
|===================================================================
|--- apps/recorder/radio.c (wersja 19415)
|+++ apps/recorder/radio.c (kopia robocza)
--------------------------
File to patch: apps/recorder/radio.c
patching file apps/recorder/radio.c
Hunk #1 succeeded at 128 (offset 7 lines).
can't find file to patch at input line 18
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|Index: apps/recorder/radio.h
|===================================================================
|--- apps/recorder/radio.h (wersja 19415)
|+++ apps/recorder/radio.h (kopia robocza)
--------------------------
File to patch:
torne:
Perhaps you should have used the -p or --strip option, then :)
This should work:
patch -p0 < additional_regions.patch
There's more than one way for a patch to refer to the files it changes, -p tells it how many parts of the path to ignore. It defaults to one, assuming the patch is referring to old-copy/apps/recorder/radio.c and new-copy/apps/recorder/radio.c (or similar). The patch you have doesn't have an old/new directory at the front, so you need to strip zero path components for it to find the files.
krawatte33:
Thanks, it works now!
I feel really stupid, of course I tried a few -p settings, but not p0.. I thought that can't be the problems because I don't want to strip anything from the path. I had no idea the default might be to strip one directory level.
I even applied patches without any problems a few months ago, so obviously I already figured it out once before.
torne:
It's a historical thing: manually generating patches with diff almost always includes one extra level of path because of the way diff is traditionally used (two copies of the source in different directories, one unmodified, one modified), so patch defaults to stripping one.
These days patches are often generated by version control tools like svn, which aren't really comparing directories but revisions, and so often choose not to put that extra level in as it conveys nothing useful. It depends what tool generated the patch, and what options the user generating the patch used, as to whether you need -p0 or -p1. (higher levels are very uncommon).
Navigation
[0] Message Index
Go to full version