I\'m currently trying to to code-style checking on the PRs of a (github) repository, and I want to deliver patches to the submitters with which they can easily fix the codes
In such cases, if you already tried all options listed below:
dos2unix
for conversiongit config --global core.autocrlf input
Another root of evil in such cases could be your IDE.
For example, some of the JetBrains IDEs like PHPStorm has following option:
After spending more than 4 bloody hours today on a weird patching issue ending up with following error:
git apply < my.git.patch --verbose
...
error: patch failed: plugins/some/file.php:74
I realized that I was victim of my editor (I am not sure if this was the default behavior).
I was using PHPStorm to check the patch file and it was silently removing a single whitespace from the patch file which literally exist on the target file that needs to be patched.
This was super sneaky and I ended up with setting Strip trailing spaces on Save for
option to None
to never hit such issue again.
Also keep in mind that platform related differences like case-sensitivity of the underlying filesystem (MacOS/Linux for eg) may also be the suspect.