• git patch 转帖


    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/

  • 相关阅读:
    Excel中输入身份证后3位变成0,怎么办?
    Css中如何使英文和拼音变成全大写、全小写和首字母大写?
    css中 font常用的样式属性
    Css的向左浮动、先右浮动、绝对定位、相对定位的简单使用
    如何解决Css属性text-overflow:ellipsis 不起作用(文本溢出显示省略号)
    mysql 基本语法学习1(数据库、数据表、数据列的操作)
    sql server中如何将两个字段数据合并成一个字段显示(字段与字段添加特殊符号)
    Linq to Entity 求最大小值Max/Min返回null的处理方法
    C#匿名对象在其它方法体内怎么取到相应的值(不想建立对应的类并转化的情况下)?
    【转发】JQuery中操作Css样式的方法
  • 原文地址:https://www.cnblogs.com/mliudong/p/2945430.html
Copyright © 2020-2023  润新知