Skip to content
Advertisement

How can I create a patch to delete a folder and create new folder using diff?

For example I have two directories say old and new. The directory old has a sub-directory abc and the directory new has a sub-directory cde. I tried creating patch by using

diff -ru old/ new/ > file.patch

I got following output in file.patch:

Only in old/: abc
Only in new/: cde

and when I tried to patch the file I got following error:

patch: **** Only garbage was found in the patch input.

When I try to create patch by using:

diff -ruN old/ new/ > file.patch

I get empty file.patch.

Is there any way to create a patch that when patched to old would delete abc and create cde in old?

Advertisement

Answer

The makepatch script is useful for this. I use this for almost all source-patches, along with diffstat. There is also applypatch (completing the task), though I do not use it myself.

The GNU diff new-file “-N” option does (used to not…) work with the recursion option “-r”. So you could use

diff -r -N old new

I just verified that it works for diff 3.0 (which by now is rather old).

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement