Need help: Generating patch using git
Subramaniam Appadodharana
c.a.subramaniam at gmail.com
Mon Jan 30 12:27:22 EST 2012
On Mon, Jan 30, 2012 at 11:21 AM, amit mehta <gmate.amit at gmail.com> wrote:
>
> 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
You can do :
3a.
git add <file1> <file2> <file3>
3b.
git commit
This will give you an editor to enter the patch info and Signed-off-by:
Save and exit will create the patch and apply it on your branch.
> # pwd
> /root/linux-next/linux-2.6
> # mkdir ../patches
> # git diff >../patches/ipconfigPatch.txt
git format-patch -1
Will give you the patch as 0001-<desc>.patch
Hope this helps.
>
> 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
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
More information about the Kernelnewbies
mailing list