I tried to apply a patch of patches (one of which essentially deletes every lines in one file and separately recreates the file with small differences and a different name - it's a rename but more than 50% different) to a file (with git apply --whitespace=fix --reject
), but I got this error message:
Checking patch path/to/file/to/patch...
error: while searching for:
<patch contents>
error: patch failed path/to/file/to/patch:1
error: removal patch leaves file contents
error: path/to/file/to/patch patch does not apply
I looked and the contents of the patch were very slightly different to the file being deleted (a line was moved up three, and had 3-4 characters removed), but what does the error message
removal patch leaves file contents
mean? Git knows this is a whole file deletion, but when it applies the patch there're lines left (as in "patch leaves file contents behind")? Or that it somehow goes out of bounds (as in "patch leaves [the] file contents")?
And why can't git figure out what to do? Git uses a similar heuristic to find file renames, I'm surprised there's not a similar process in place. Also using -3
fails to apply all the patches, otherwise I would have had an easier time confirming I found all the changes.