You are not logged in.

#1 2018-10-19 17:48:21

jasin
Member
Registered: 2018-10-15
Posts: 10

git diff and patching

during my recent ventures with kernel compilation I've run into something I can't quite explain the reason behind

I tried to patch a file, in this case module.c. I cloned the repository, then did a git checkout of a commit. Then I edited the file module.c with the updated line of code. Just one line! Then I ran git diff and pushed it to a patch file. Next I did a git checkout of the module.c file to return it to the original state. Next up I tried patching the file using patch and the patch file. Failure

what am I missing?

laptop% nvim arch/x86/kernel/module.c 
laptop% git diff
diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
index 005c03e93fc5..71019b5c9bbc 100644
--- a/arch/x86/kernel/module.c
+++ b/arch/x86/kernel/module.c
@@ -183,6 +183,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
                                goto overflow;
                        break;
                case R_X86_64_PC32:
+               case R_X86_64_PLT32:
                        val -= (u64)loc;
                        *(u32 *)loc = val;
 #if 0
laptop% 
laptop% nvim plt32.diff
laptop% git checkout arch/x86/kernel/module.c 
laptop% patch -p1 -i plt32.diff 
patching file arch/x86/kernel/module.c
Hunk #1 FAILED at 183.
1 out of 1 hunk FAILED -- saving rejects to file arch/x86/kernel/module.c.rej

Offline

#2 2018-10-19 22:07:39

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,836

Re: git diff and patching

Why is there an nvim call? What does the actual patch file look like? Does it work if you "git diff > plt32.diff"?

Offline

#3 2018-10-20 13:14:16

jasin
Member
Registered: 2018-10-15
Posts: 10

Re: git diff and patching

it does work that way. Must be I was missing a newline or something. Either that or the git diff output was altered printing to console.

Now I wonder what exactly it is I’m missing. I copied the entire line from console up to the next prompt. According to Nvim and cat there is no newline. I have no idea what I’m missing doing it the select & shift+ins.

But lesson learned

Offline

#4 2018-10-20 13:30:21

a821
Member
Registered: 2012-10-31
Posts: 394

Re: git diff and patching

maybe the file have tabs and by copying and pasting the tabs are transformed into spaces?

Offline

#5 2018-10-20 14:04:42

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,836

Re: git diff and patching

Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Offline

Board footer

Powered by FluxBB