Guidelines for GStreamer developers
Best practices and git use guidelines for GStreamer developers and contributors
This document is a draft and by no means complete. If in doubt, ask in the IRC channel.
Committing
- make sure you have registered your full name and e-mail address for git on the machine you're committing from (see below)
- don't commit merges, rebase (if you look at the graph in gitk or giggle, it should be a straight line from the current HEAD of master to origin/master)
- The one exception to this if for surgery/brown-paperbag releases which require creating a separate branch for the release, but then has to be merged back.
- commit messages:
- please take the time to write good and concise commit messages
- if you don't, people may make fun of you in public
the first line of the commit message should be a short and concise summary of the commit. If it applies only to a specific subsystem or plugin, prefix the message with the subsystem, e.g.: oggdemux: fix granulepos query for the old theora bitstream
- the second line should be empty
- the third and following lines should contain an extensive description of the change made: what was changed, what was broken, how did it get fixed, what bugs or issues does this fix? Trivial commits do not require a description.
- bug numbers should always go into the description, not into the summary line (if there is no description block, make one)
- we do no longer include the files changed in the commit message, tools like gitk and giggle will show these, the commit mails will also have this information
- we do no longer include the function names in the commit message, although you may of course include them where it makes sense
we no longer maintain a ChangeLog file in the repository
add a Based on patch by: John Bleh <john@bleh.com>' to the end of the commit message if the patch is based partly on someone else's work but you are not going to use git commit --author for this patch.
- don't commit things that aren't relevant to your change, such as modified .po files, win32/common/config.h etc.
you can revert locally modified files to the version in git with git checkout files, e.g. git checkout po/*po
- don't commit multiple unrelated changes in one go, commit them separately (use your judgement; if in doubt, do separate commits)
use git commit --author='John Bleh <john@bleh.com>' files to commit someone else's patch.
make sure not to accidentally change the version of the common submodule used when you commit things; if git diff shows that common changed, run git submodule update or git reset common to fix it. In general, try to avoid using commit -a, but instead explicitly do git add <files you want to commit>; git commit or just git commit <files or directories you want to commit>.
Remote branches
don't push your own work branches to the main gstreamer repository; you can create a personal repository on people.freedesktop.org and push your personal branches there: Instructions for creating a personal git repository on people.freedesktop.org
Merging branches
- avoid 'merge commits' by:
- rebasing your branch to master before merging it into master:
git checkout branch git rebase master git checkout master git merge branch
- or doing git rebase origin/master on master after merging - this should get rid of any merge commits:
checkout master merge branch rebase origin/master
You might also want to use git pull --rebase instead of git pull when you update.
Pushing changes
- do review the commits you are about to push to the public repository in gitk or giggle or the like
- make sure your name and e-mail is set correct on all the commits (no local host names in e-mail address etc.)
- make sure the author is set correctly for all commits where you applied someone else's patch
before pushing, make sure the module in question isn't frozen due to release being prepared. You are expected to check the #gstreamer IRC channel topic and the mailing list for this. If you haven't checked, don't push. Check the ReleasePlanning page for when to expect releases.
do NOT push work branches to the official repositories, use a personal repository if you want them stored somewhere visible (see Personal repositories below)
Committing changes that deprecate API
see DeprecatingAPI for details
Adding new API
New API covers things such as:
- new exported functions which are added to an installed header file (mostly core, -base and -gl libraries)
- new enums or flags in installed header files (mostly core, -base and -gl libraries)
- new GObject properties on core library or plugins library objects, or elements in -base, -good or -ugly
- new structure members in installed header files (mostly core, -base and -gl libraries; plugin/element headers are usually not installed, so you can change those as much as you like)
- new plugins/elements being added to GStreamer core, -base, -good, or -ugly
- basically most things which we can't easily change without breaking things once they've been in a release
Generally, new API should be reviewed before being committed, especially new core or core/-base libs API (in practice you'll find that there is a bit of a gray area here and the rule does not always apply to module maintainers or lead developers).
Getting your new API reviewed is best done by filing an enhancement bug against the module in question and attaching a patch which adds the new API and includes a gtk-doc blurb (don't forget the 'Since: 0.10.x' at the end of the gtk-doc blurb and adding your new function to the appropriate -sections.txt file in the docs/ directory). Mark the bug summary with the [API] keyword for extra attention. Then either wait until you get feedback, or poke people on IRC to have a look at it. If you don't get feedback, keep poking. Don't assume it's ok to commit/push new API just because no one raised any objections.
Some simple unit tests for the new API are always a good thing too.
Adding properties
If you're adding new properties, please add a gtk-doc chunk with a 'Since:' tag for the property, e.g.
/**
* GstPipeline:delay
*
* The expected delay needed for elements to spin up to the
* PLAYING state expressed in nanoseconds.
* see gst_pipeline_set_delay() for more information on this option.
*
* Since: 0.10.5
**/
g_object_class_install_property (gobject_class, PROP_DELAY,
g_param_spec_uint64 ("delay", "Delay",
"Expected delay needed for elements "
"to spin up to PLAYING in nanoseconds", 0, G_MAXUINT64, DEFAULT_DELAY,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Committing new API
Use the 'API:' keyword in the body of the commit message when adding new API (ie. exported functions, GObject vfuncs, GObject properties or GObject signals), e.g.:
Add API to intercept flow returns. ...extensive description... API: gst_pad_add_flow_probe()
or
fakesrc: add format property to control the format of the newsegment events. API: GstFakeSrc:format
(There is not exact format for this stuff, just make sure to use the keyword to make life easier for the release manager)
Tools
- git
git-bz: bugzilla subcommand for git
giggle: A gtk-based git viewer. A must-have to have a better grasp at what is going on in git.
We don't maintain a ChangeLog file in git any longer, but auto-generate it upon release from the git commit messages. Therefore it is no longer necessary to use tools like moap, prepare-ChangeLog.pl or cicl
setting up your name and e-mail address
$ git config --global user.name "FirstName LastName" $ git config --global user.email "user@example.com"
See the Git Guide for more setup options (colours etc.)
Personal repositories
Explanations available here for creating a personal repository on freedesktop.org (if you have an account there) : http://www.freedesktop.org/wiki/Infrastructure/git/RepositoryAdmin
There are many other git hosting facilities out there if you don't have a freedesktop.org account (github.org and gitorious.org for example).
Once you have created a personal repository, you can locally add that repository to the list of remote repositories your local checkout is tracking (let's say we created a personal repo for storing our work branches for work on gstreamer core):
$ me@local> cd gstreamer.git $ me@local> git remote add myrepo ssh://people.freedesktop.org/~username/gstreamer
If you have a local work branch (called 'mywork') you can now push it to your personal repository
$ me@local> git push myrepo mywork:mywork
Random notes
don't #include <stdint.h>, use #include "_stdint.h" or #include <_stdint.h>
in Makefile.am, the order of the various CFLAGS and LIBS arguments matters, e.g. it should be $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(LIBFOO_CFLAGS)
Also see
GitResources: random collection of git-related documentation, tutorials, screencasts and cheat sheets

