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!