Is it possible to add a full directory via diff and patch?
It seems as very convenien开发者_开发问答t way to add additional modules on top of standard code-base.
I googled for some solutions, but they generally work on file level, not on directory level.
Thanks.
Answering myself:
diff -urPp old_dir/ new_dir/ > new_module.patch
Seems to do the trick.
Two quick suggestions--these should help
You need the flag
-r | --recursive
You probably also need
--unidirectional-new-file
or-N | --new-file
.
as I have done what you have in mind here.
Below steps will work
- Taking patch between the old source code and new source code (new files + new directories) diff -urPp old_src new_src > new.patch
- create a temp directory mkdir temp
- copy the original old source code directory to temp directory cp -r old_src temp
- copy the patch file to temp directory created cp new.patch temp
- change directory cd temp
- apply patch patch -p0 < new.patch
Now all the patches would be applied with file changes + new files + directory addition in the temp directory
精彩评论