开发者

Adding full directory via diff & patch

开发者 https://www.devze.com 2023-01-22 05:48 出处:网络
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.

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

  1. You need the flag -r | --recursive

  2. 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

  1. Taking patch between the old source code and new source code (new files + new directories) diff -urPp old_src new_src > new.patch  
  2. create a temp directory mkdir temp  
  3. copy the original old source code directory to temp directory cp -r old_src temp  
  4. copy the patch file to temp directory created cp new.patch temp  
  5. change directory cd temp  
  6. apply patch patch -p0 < new.patch  

Now all the patches would be applied with file changes + new files + directory addition in the temp directory

0

精彩评论

暂无评论...
验证码 换一张
取 消