Can a patch be safely applied?

Is it possible to assume that after successful

patch < mypatch 

back

 patch -R < mypatch 

will always be successful, and make previous changes exactly undone?

I know that there are several patch formats and, of course, many patch / diff programs, so if it’s relevant, indicate which versions / systems you are linking.

+4
source share
1 answer

Patch files should work in reverse order. Generally speaking, patches simply list the lines added and deleted lines. Using -R simply swaps them too, making the added lines look like deleted lines, and the deleted lines look like added lines.

As long as you haven’t changed anything after the patch, deleting should always work.

+1
source

All Articles