Sounds like a problem for rediff (<a href="https://github.com/twaugh/patchutils">https://github.com/twaugh/patchutils</a>).<p>Instead of directly editing the unified diff file, make a copy and edit the copy. Once you’re done, call rediff original-patch edited-patch to get a patchfile with fixed offsets.<p>Note that rediff only fixes your offsets, and doesn’t remove empty hunks. patch is not happy about empty hunks existing, so if you happen to revert all changes in a hunk, remember to delete the hunk after rediff. Probably this ought to be contributed back upstream.