Need help: Generating patch using git

amit mehta gmate.amit at gmail.com
Mon Jan 30 12:21:25 EST 2012


Hi,

kernel janitors group seem like a good place to start learning linux kernel and
after reading some of the information available on kernel newbies website, i
tried to generate a dummy patch and need your help for moving in correct
direction of learning and contributing to linux kernel. So these are
the steps that i've followed to generate this dummy patch.

1: Download the latest linux kernel sources using git
# mkdir linux-next
# cd linux-next
# git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
linux-2.6

2: Do some modifications.
# pwd
/root/linux-next/linux-2.6

# git diff
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 6e412a6..9858701 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -441,7 +441,7 @@ static int __init ic_defaults(void)
                                &ic_myaddr);
                        return -1;
                }
-               printk("IP-Config: Guessing netmask %pI4\n", &ic_netmask);
+               printk(KERN_INFO "IP-Config: Guessing netmask %pI4\n",
&ic_netmask);
        }

        return 0;

3: Generate a patch
# pwd
/root/linux-next/linux-2.6
# mkdir ../patches
# git diff >../patches/ipconfigPatch.txt

4: Test your patch
4a: Clear the local changes from the tree
# git checkout -f

4b: Apply the patch
# git apply ../patches/ipconfigPatch.txt


The above step(4b) did not returned any git error so it seems to me that the
steps to generate this patch was correct.

5: Check your mailer
5a: I just copied the contents of ../patches/ipconfigPatch.txt and pasted in
the compose area and sent that mail to myself. After receiving this mail i
copied and pasted the mail contents in a file under
/root/linux-next/patches/dummyPatch.txt and tried to apply this patch
using git but it gave me an error as below:
# git apply ../patches/dummy.txt
fatal: corrupt patch at line 11

Hence it seems i'm missing something here. Please note that this is just for my
understanding purpose of generating and submitting patches.

-Amit



More information about the Kernelnewbies mailing list