User Tools

Site Tools


writeandsubmitpatch

This is an old revision of the document!


WriteAndSubmitPatch

If you want to contribute code to linux-minidisc but don't have write access to our git repository, you can use git to create and submit patches. git is so powerful that it already brings all the functionality necessary to perform patch management. Essentially, writing and submitting a patch can be split up into 5 single tasks:

  • checking out the git repository
  • creating a git branch for your patches
  • editing the source and committing the changes in your branch
  • creating a patch in .diff format
  • sending the patch to the mailing list

All these tasks can be performed with git, except, of course, you still need an editor to make your changes to the source.

Checking out the git repository

Checking out the code is very simple, once you have git installed, run:

git clone git://z6.physik.fu-berlin.de/linux-minidisc

The source tree will be checked out into the folder linux-minidisc in the current working directory. After check out, just change into the folder and off you go:

cd linux-minidisc

Creating a local branch

Creating a branch is important, so that you don't mess with the main codeline. Branches will also help you to create patches very easily as you will see in the following sections. The default branch (or the main codeline) is called master. To create your own branch, just invoke:

git branch mybranch

Will create the new branch mybranch. To list the available branches, type:

git branch

It should also list the branch master as the current working branch. To actually change the current working branch, use git checkout:

git checkout mybranch

Check again with git branch that you are working on mybranch now.

Editing the source and committing the changes

Now you can simply start editing the source code, all changes will be committed to mybranch and not affect the master branch.

After editing and saving your changes to the code, you can use git status to check your changes.

git status

To have a more detailed information about the changes, use git diff and git show.

If you're content with your changes, it's time to commit them to your local branch mybranch. Use git commit for that:

git commit -a

Note that the option -a here makes sure, that all your changes since the last commit will be committed. If you only want to commit certain changes, use git add to specify the files in the source tree which are to be included in the commit.

Creating a patch in .diff format

With the help of git, creating the actual .diff file is very easy. You don't even need to mess with tools like diff directly, git will do all the work for you.

To create a diff with your changes with the respect to the branch master, use git format-patch:

git format-patch master..mybranch

This will create patches for all your changes to the git tree, ready to be sent to the linux-minidisc mailing list.

Sending the patch to the mailing list

You may now use your preferred mail client to send patches to the linux-minidisc mailing list. However, since some mail clients may mess up the format of the patch, it's recommended to use the built-in command git send-email to send the patches in to the mailing list:

git send-email 0001-my-first-patch.patch --to linux-minidisc@lists.fu-berlin.de

Provided that your local mail daemon is configured properly on your Linux machine, git will automatically use it to send the patch to the mailing list. You may also send several patches at the same time by specifying them on the command line. If you're not running a local mail daemon on your Linux machine or you are using Windows or MacOS, you need to edit your git configuration. It can be found in the folder .git-config in your home directory.

Congratulations, you should now be able to send in your first patch. Feel free to play around and also just send sample patches to the mailing list to get used to the system.

writeandsubmitpatch.1265919077.txt.gz · Last modified: 2010/02/11 20:11 by glaubitz

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki