3

I'm naïve vis-à-vis patch and unified diffs. I have a C source file that needs two independent patch files applied. In other words, file Frodo.patch contains Frodo-specific patches; file Bilbo.patch contains Bilbo-specific patches. The two patches are completely unrelated.

So, say I apply Frodo.patch to hobbits.c, creating a new hobbits.c Works fine. Next I apply Bilbo.patch to the new hobbits.c (which was patched using Frodo.patch) and the patch process fails:

patching file hobbits.c
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file...

Ok, so I understand the diff markers probably don't accommodate this scenario. But there must be some way to do this. If I run an open-source project that receives patch-files as updates to the same source file, these files will be unrelated but they're somehow successfully applied to create an updated version.

Hopefully I've explained the scenario clearly. So question: how do I maintain and successfully apply two unrelated patch files for the same source file?

Thanks very much.

2
  • 1
    If they're completely unrelated—the affected lines are not next to each other—they should both apply without issue. Otherwise, you will have to resolve the conflicts manually in some fashion. Whether you do that by reading through the patch files yourself and typing in the edits yourself (bad idea) or running a program that will show you each patch hunk and let you choose where/how to apply it—you have still left the field of automatic patching to some degree and will need to do things manually. Commented Dec 10, 2015 at 22:44
  • I was afraid that would be the answer. You are correct about the automatic process; currently patching this file is part of a scripted build run. Thanks for taking the time to answer. Commented Dec 14, 2015 at 14:48

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.