博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux diff patch
阅读量:6443 次
发布时间:2019-06-23

本文共 3661 字,大约阅读时间需要 12 分钟。

/***************************************************************************** *                            Linux diff patch * 声明: *     经常需要给代码打补丁,但是发现自己不会打补丁,经常看着补丁改代码,效率 * 那是一个低啊,不会就学学呗,反正patch有-R回退,不怕出错。 * *                                      2015-12-28 深圳 南山平山村 曾剑锋 ****************************************************************************/                    \\\\\\-*- 目录 -*-//                    |  参考文章:                    |  一、cat main1.c                    |  二、cat main2.c                    |  三、execute diff:                    |  四、execute patch:                    |  五、patch back:                    -----------------------参考文章:    1. 用Diff和Patch工具维护源码        http://www.ibm.com/developerworks/cn/linux/l-diffp/index.html    2. diff和patch使用指南        http://www.cnblogs.com/cute/archive/2011/04/29/2033011.html    3. 补丁格式 diff patch        http://blog.sina.com.cn/s/blog_51cea4040101atql.html一、cat main1.c    #include 
int main( int argc, char **argv ) { printf( " zengjf test for diff and patch.\n" ); }二、cat main2.c #include
int main( int argc, char **argv ) { printf( " zengjf test for diff and patch.\n" ); }三、execute diff: 1. $: diff -Nur main1.c main2.c > main.patch 2. 在当前目录下生成了main.patch文件: --- main1.c 2015-12-28 20:36:49.388152208 +0800 +++ main2.c 2015-12-28 20:25:17.376180914 +0800 @@ -2,5 +2,8 @@ int main( int argc, char **argv ) { + + + printf( " zengjf test for diff and patch.\n" ); }四、execute patch: 1. 当前目录下有:main1.c main2.c main.patch 2. cat main1.c #include
int main( int argc, char **argv ) { printf( " zengjf test for diff and patch.\n" ); } 3. $: patch -p0 < main.patch
patching file main1.c 4. cat main1.c #include
int main( int argc, char **argv ) { printf( " zengjf test for diff and patch.\n" ); } 5. $: patch p0 < main.patch
patching file p0 Hunk #1 FAILED at 2.out of hunk FAILED -- saving rejects to file p0.rej 6. $: patch -p1 < main.patch
can't find file to patch at input line 3 Perhaps you used the wrong -p or --strip option? The text leading up to this was: ---------------------------------- |--- main1.c 2015-12-28 20:36:49.388152208 +0800 |--- main2.c 2015-12-28 20:25:17.376180914 +0800 ---------------------------------- File to patch:
7. $: patch -p0 main.patch
^C五、patch back: 1. 当前目录下有:main1.c main2.c main.patch 2. cat main1.c #include
int main( int argc, char **argv ) { printf( " zengjf test for diff and patch.\n" ); } 3. $: patch -p0 -R < main.patch patching file main1.c 4. cat main1.c #include
int main( int argc, char **argv ) { printf( " zengjf test for diff and patch.\n" ); }六、实例分析: 1. patch 部分内容: diff --git a/proguard.flags b/proguard.flags index 6d41d17..ffbc39a 100644 --- a/proguard.flags +++ b/proguard.flags @@ -11,4 +11,4 @@ -keep class com.android.settings.MasterClearConfirm -keep class com.android.settings.accounts.* -keep class com.android.settings.fuelgauge.* - +-keep class com.android.settings.ethernet.* 2. 解析:@@ -11,4 +11,4 @@ 1. @@ -表示代表a/proguard.flags文件; 2. 11代表下面显示的代码是从a/proguard.flags文件的第11行开始; 3. 4代表a/proguard.flags被操作了; 4. +代表b/proguard.flags文件 5. 11代表下面显示的代码是从b/proguard.flags文件的第11行开始; 6. 4代表b/proguard.flags被操作了; 7. @@ 代表结束

 

转载于:https://www.cnblogs.com/zengjfgit/p/5084040.html

你可能感兴趣的文章
CentOS LAMP环境 配置详解
查看>>
任正非:华为为什么要坚持工业科学管理
查看>>
实现法线贴图3D模型渲染的脚本代码(附源码)
查看>>
iPhone开发面试题--葵花宝典
查看>>
05-Git
查看>>
Spring quartz 单机、集群+websocket集群实现文本、图片、声音、文件下载及推送、接收及显示...
查看>>
SPOJ104 Highways,跨越数
查看>>
使用rman备份异机恢复数据库
查看>>
Win7-64bit系统下安装mysql的ODBC驱动
查看>>
自己做一款简易的chrome扩展--清除页面广告
查看>>
node中非常重要的process对象,Child Process模块
查看>>
Webserver管理系列:3、Windows Update
查看>>
Linux内核源码详解——命令篇之iostat[zz]
查看>>
Sqlserver2000联系Oracle11G数据库进行实时数据的同步
查看>>
duplicate命令创建physical standby数据库报RMAN-03015 ORA-17628
查看>>
明年计划
查看>>
ORACLE功能GREATEST功能说明具体实例
查看>>
unity, particle play once and destroy
查看>>
hadoop job解决大数据量关联时数据倾斜的一种办法
查看>>
windows配置nginx实现负载均衡集群
查看>>