Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow patches with prefix a/ and b/ (try using -p1 if -p0 fails) #428

Closed
prof7bit opened this issue Sep 4, 2021 · 2 comments
Closed

allow patches with prefix a/ and b/ (try using -p1 if -p0 fails) #428

prof7bit opened this issue Sep 4, 2021 · 2 comments

Comments

@prof7bit
Copy link
Contributor

prof7bit commented Sep 4, 2021

When using git it will become commonplace to have patches formatted with git diff or git format-patch and these prepend by default prefixes like a/ and b/ in front of the paths. A patch created by git diff and usable by git apply or by patch -p1 starts with a header like this:

diff --git a/ide/projectinspector.pas b/ide/projectinspector.pas
index 26ba1a2244..4ee5b58a49 100644
--- a/ide/projectinspector.pas
+++ b/ide/projectinspector.pas

while a patch acceptable by patch -p0 (current only possibility in fpcupdeluxe) would need to start like this:

diff --git a/ide/projectinspector.pas b/ide/projectinspector.pas
index 26ba1a2244..4ee5b58a49 100644
--- ide/projectinspector.pas
+++ ide/projectinspector.pas

As it turns out now I have to edit all patch files I receive from devs while trying to test their changes by hand to remove the prefixes or tell them to generate then with git diff --no-prefix which is very uncommon and nobody does this.

I would change the patching logic such that if it fails to apply the patch with -p0 also try again to apply it with -p1. Or maybe even the other way around and try -p1 first because most patches will now come straight out of git and will be of the -p1 type.

Also you should add the -t option for batch processing, so it outputs an error instead of trying to read user input from stdin.

@prof7bit prof7bit changed the title allow patches with prefix a/ and b/ (also try using -p1 if -p0 fails) allow patches with prefix a/ and b/ (try using -p1 if -p0 fails) Sep 4, 2021
@LongDirtyAnimAlf
Copy link
Owner

@prof7bit
Copy link
Contributor Author

prof7bit commented Sep 9, 2021

Is working, tested with both types of patches :-)

closing this bug

@prof7bit prof7bit closed this as completed Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants