0

I'm not sure if I'm missing something or if this is a missing feature but occasionally when I attempt to apply a patch from my mail box git completely fails to apply it.

This isn't a case of resolving merge conflicts rather than having to apply the patch by hand. magit helpfully provides a link to the failed patch but there doesn't seem to be an obvious way to launch into ediff from here.

I end up going into the patch, running M-x diff-mode and manually applying the patch (after having to convince it of the root path for files). Am I missing something here? Or is dealing with failed to apply patches too tricky to programaticaly aid?

3
  • It kind of depends on why the patch application failed. And I'm not clear what you expect ediff to do.
    – npostavs
    Feb 25, 2019 at 13:53
  • I thought ediff had an interactive patch application method (ediff-patch) which I was hoping would be less cumbersome than working through diff-mode. I'd even take being able to pipe the patch to patch -p1 from ! s.
    – stsquad
    Feb 25, 2019 at 13:55
  • I think you should be able to use a or w a on the patch item in the status screen (been a while since I've last done this though). I didn't know about ediff-patch-file; I don't believe magit currently has any integration with it, perhaps that should be added.
    – npostavs
    Feb 27, 2019 at 3:13

1 Answer 1

2

I'm not sure if I'm missing something or if this is a missing feature but occasionally when I attempt to apply a patch from my mail box git completely fails to apply it.

This probably just means that the current state has diverged too much since the patch was created for git am to figure out where to apply it.

This isn't a case of resolving merge conflicts rather than having to apply the patch by hand. magit helpfully provides a link to the failed patch but there doesn't seem to be an obvious way to launch into ediff from here.

If history has diverged so much for git am to fail to even determine where the user has to resolve conflicts, then algorithms used by other tools are likely to fail too. Ediff itself can only compare different version of one thing with one another. Since you only have one version and the difference between two other versions it does not have the inputs it needs.

Even if you had the two version (i.e. the contributor had send you a new version of the file instead of a diff) I expect that Ediff would just find one conflicting area, consisting of the complete file.

In summary, I believe this is one of those cases where you have no choice but to do things manually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.