设为首页 收藏本站
查看: 610|回复: 0

[经验分享] git patch 转帖

[复制链接]

尚未签到

发表于 2018-1-16 07:37:13 | 显示全部楼层 |阅读模式
  Today learned some things about git and applying patches. First when applying my trec/ace/kshmem patches to 2.6.25-rc2 they wouldn’t apply because now there only an x86 architecture (arch/x86) instead of two architectures i386 and x86_64. That was to be expected actually and there’s going to be some hand work in doing that.
  To do this hand work I really need to see what my current patches look like and there isn’t quite enough context in the patch file to do that, at least for me. So I cloned the current linux-2.6 tree into a new directory linux-2.6-x and did a checkout of 2.6.21-rc6 which is what my patches should apply against.
  Well almost, there was still some need for a little tweaking; First git am will take my series of patches which were generated using git format-patch and apply them extracting from the email the commit message and the patch. It then creates a commit. But if there is a problem in a series only those that applied cleanly will be committed.
  The first patch that fails won’t be applied at all, for example:

  

error: patch failed: mm/vmalloc.c:469  
error: mm/vmalloc.c: patch does not apply
  
Patch failed at 0002.
  
When you have resolved this problem run "git-am --resolved".
  
If you would prefer to skip this patch, instead run "git-am --skip".
  

  At this point I was scratching my head Patch failed at 0002 and when its resolved I can say so, but how to resolve it if its not been applied to the working tree. The solution is to use “git apply”:

  

git apply --reject --whitespace=fix my-patches/ace2-2.6.21-rc6/0002.patch  

  By using “git apply” with the –reject it will apply the patch leaving bad files with “xxx.rej” in my case mm/Kconfig.rej was the culprit. I resolved the problem with mm/Kconfig. Next I tried “git am –resolved”:

  

wink@ic2d1:$ git am --resolved  
Applying ACE implementation, conifguration and makefile
  
No changes - did you forget to use 'git add'?
  
When you have resolved this problem run "git-am --resolved".
  
If you would prefer to skip this patch, instead run "git-am --skip"
  

  More head scratching, “did you forget to use ‘git add’?” …. hm Ok so I then used “git gui” to add the files (BUT DID NOT DO A COMMIT) and then did “git am –resolved”:

  

wink@ic2d1:$ git am --resolved  
Applying ACE implementation, conifguration and makefile
  
Applying ACE modifications to actually use ACE
  
.dotest/patch:32: trailing whitespace.
  
warning: 1 line adds whitespace errors.
  
Applying ACE simple test program
  
.dotest/patch:130: space before tab in indent.
  
result ? "true" : "false", i);
  
.dotest/patch:138: space before tab in indent.
  
result ? "true" : "false", i);
  
.dotest/patch:146: space before tab in indent.
  
result ? "true" : "false", i);
  
.dotest/patch:233: trailing whitespace.
  
warning: 4 lines add whitespace errors.
  

  That did it, so no commit was necessary, the “git am –resolved” did the commit and then continued with the other patches. Lean something new everyday!
  文本来源:http://www.winksaville.com/blog/linux/git-applying-patches/

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-435555-1-1.html 上篇帖子: git push 403的解决方法 下篇帖子: git 创建 .gitignore 文件 建立项目过滤规则
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表