Need help: Generating patch using git

amit mehta gmate.amit at gmail.com
Mon Jan 30 13:33:25 EST 2012


On Mon, Jan 30, 2012 at 11:02 PM, Srivatsa Bhat <bhat.srivatsa at gmail.com> wrote:
>
>
> On Mon, Jan 30, 2012 at 10:51 PM, 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
>> # pwd
>> /root/linux-next/linux-2.6
>> # mkdir ../patches
>> # git diff >../patches/ipconfigPatch.txt
>>
>
> Strictly speaking,  a complete patch has many more things, like
> a commit message, Signed-off-by line etc. Of course, if you are just
> playing around with patches just for fun, you need not worry about this.
> But if you want to contribute to the linux kernel, you would need to take
> care of all that.
>
> So, for that, instead of git diff, use:
>
> # git commit -a
> Type an appropriate commit message and add your Signed-off-by.
> (Your git configurations can help you automate stuff like Signed-off-by).
>
> # git format-patch -1 HEAD
> This will generate the patch for you. You can mail this using git send-email
> or by copy pasting it in your email client.
>
> You can refer to the video by Greg about submitting patches.
> http://www.youtube.com/watch?v=LLBrBBImJt4
>
>> 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
>>
>
> Ah, I think your email client corrupted it! (white-space damage perhaps)
> Check out Documentation/email-clients.txt for more info on how to make your
> email clients behave :-)
>

Thank you so much. I'll check the links that you've suggested.

-Amit



More information about the Kernelnewbies mailing list