neilbrown / wiggle

apply rejected patches and perform word-wise diffs
http://neil.brown.name/wiggle
GNU General Public License v2.0
91 stars 8 forks source link

Question: apply git patch #5

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hi! I'm curious if wiggle can help me solve my problem: I generated patches with git format-patch origin/master command on one repo and now I want to apply them on slightly different repo. If i do patch -p1 < 0001-*.patch, it fails sometimes with Hunk #1 FAILED at 1 errors. Is it possible to apply patch to files in a directory and fix these problems with wiggle somehow? Thanks!

neilbrown commented 9 years ago

On Wed, 24 Sep 2014 22:51:03 -0700 Constantine notifications@github.com wrote:

Hi! I'm curious if wiggle can help me solve my problem: I generated patches with git format-patch origin/master command on one repo and now I want to apply them on slightly different repo. If i do patch -p1 < 0001-* it fails sometimes with Hunk #1 FAILED at errors. Is it possible to apply patch to files in a directory and fix these problems with wiggle somehow? Thanks!

Yes. Did you try it?

I would use "wiggle -Bp 0001-*" and then explore around. Use "?" for help.

NeilBrown

ghost commented 9 years ago

Thank you! Didn't know which command to use... wiggle -Bp 0001-*.patch --strip . did the work, but now I can't proceed further, it shows this menu:

Ch Wi Co Patched Files
         + b/src/repo
 2 -1 -1 = b/src/repo/main.cpp

2 -1 -1 = b/src/repo/main.cpp line is red and when I click on the line it says The file that this patch applies to appears to be missing. Please type 'q' to continue and returns to that menu with red lines for files that don't exist. They don't existed before the patch, but the patch contains them and has to create them. Is there any flag that can fix it?

ghost commented 9 years ago

Chunk of the patch file for creating a new source file looks like this:

diff --git a/src/repo/main.cpp b/src/repo/main.cpp
new file mode 100644
index 0000000..cbd4b3b
--- /dev/null
+++ src/repo/main.cpp
@@ -0,0 +1,1 @@
+int main() {}
neilbrown commented 9 years ago

On Thu, 25 Sep 2014 05:00:19 -0700 Constantine notifications@github.com wrote:

Chunk of the patch file for creating a new source file looks like this:

diff --git a/src/repo/main.cpp b/src/repo/main.cpp
new file mode 100644
index 0000000..cbd4b3b
--- /dev/null
+++ src/repo/main.cpp
@@ -0,0 +1,1 @@
+int main() {}

Wiggle isn't able to create new files from patches against /dev/null. Probably it would be useful to add that.

Another approach you can take is to run "patch" and then run "wiggle" on each of the .rej files. So

wiggle -r file file.rej

while just "wiggle" the rej in - you should then check that it worked. Or wiggle -B file file.rej

will let you see how the rejected patch can be wiggled in.

NeilBrown

ghost commented 9 years ago

Thanks, Neil! I'll try that. I think the issue can be closed now.