2016-01-28 00:56:16 +03:00
Submitting patches
------------------
2016-03-30 16:19:38 +03:00
A majority of current maintainers prefer the Github pull request
model, and this motivated moving the primary git repository to
< https: / / github . com / ostreedev / ostree > .
2016-01-28 00:56:16 +03:00
2016-03-30 16:19:38 +03:00
However, we do not use the "Merge pull request" button, because we do
not like merge commits for one-patch pull requests, among other
reasons. See [this issue ](https://github.com/isaacs/github/issues/2 )
for more information. Instead, we use an instance of
[Homu ](https://github.com/servo/homu ), currently known as
`cgwalters-bot` .
2016-01-28 00:56:16 +03:00
2017-02-03 10:03:06 +03:00
As a review proceeds, the preferred method is to push `fixup!`
2016-03-30 16:19:38 +03:00
commits via `git commit --fixup` . Homu knows how to use
`--autosquash` when performing the final merge. See the
2016-11-22 16:04:52 +03:00
[Git documentation ](https://git-scm.com/docs/git-rebase ) for more
2016-03-30 16:19:38 +03:00
information.
2016-01-28 00:56:16 +03:00
2016-03-30 16:19:38 +03:00
Alternative methods if you don't like Github (also fully supported):
2016-01-28 00:56:16 +03:00
2016-03-30 16:19:38 +03:00
1. Send mail to < ostree-list @ gnome . org > , with the patch attached
1. Attach them to < https: // bugzilla . gnome . org />
It is likely however once a patch is ready to apply a maintainer
will push it to a github PR, and merge via Homu.
2016-03-16 22:02:18 +03:00
2016-03-30 16:19:38 +03:00
Commit message style
--------------------
2016-01-28 00:56:16 +03:00
2016-03-30 16:19:38 +03:00
Please look at `git log` and match the commit log style, which is very
similar to the
[Linux kernel ](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git ).
2016-01-28 00:56:16 +03:00
2016-03-30 16:19:38 +03:00
You may use `Signed-off-by` , but we're not requiring it.
2016-01-28 00:56:16 +03:00
2016-03-30 16:19:38 +03:00
Running the test suite
----------------------
2016-01-28 00:56:16 +03:00
2016-03-30 16:19:38 +03:00
OSTree uses both `make check` and supports the
[Installed Tests ](https://wiki.gnome.org/GnomeGoals/InstalledTests )
model as well (if `--enable-installed-tests` is provided).
2016-01-28 00:56:16 +03:00
Coding style
------------
Indentation is GNU. Files should start with the appropriate mode lines.
Use GCC `__attribute__((cleanup))` wherever possible. If interacting
with a third party library, try defining local cleanup macros.
Use GError and GCancellable where appropriate.
Prefer returning `gboolean` to signal success/failure, and have output
values as parameters.
Prefer linear control flow inside functions (aside from standard
loops). In other words, avoid "early exits" or use of `goto` besides
`goto out;` .
This is an example of an "early exit":
static gboolean
myfunc (...)
{
gboolean ret = FALSE;
2016-03-16 22:02:18 +03:00
2016-01-28 00:56:16 +03:00
/* some code */
2016-03-16 22:02:18 +03:00
2016-01-28 00:56:16 +03:00
/* some more code */
2016-03-16 22:02:18 +03:00
2016-01-28 00:56:16 +03:00
if (condition)
return FALSE;
2016-03-16 22:02:18 +03:00
2016-01-28 00:56:16 +03:00
/* some more code */
2016-03-16 22:02:18 +03:00
2016-01-28 00:56:16 +03:00
ret = TRUE;
out:
return ret;
}
If you must shortcut, use:
if (condition)
{
ret = TRUE;
goto out;
}
A consequence of this restriction is that you are encouraged to avoid
deep nesting of loops or conditionals. Create internal static helper
functions, particularly inside loops. For example, rather than:
while (condition)
{
/* some code */
if (condition)
{
for (i = 0; i < somevalue ; i + + )
{
if (condition)
{
/* deeply nested code */
}
2016-03-16 22:02:18 +03:00
2016-01-28 00:56:16 +03:00
/* more nested code */
}
}
}
Instead do this:
2016-03-16 22:02:18 +03:00
2016-01-28 00:56:16 +03:00
static gboolean
helperfunc (..., GError **error)
{
if (condition)
{
/* deeply nested code */
}
2016-03-16 22:02:18 +03:00
2016-01-28 00:56:16 +03:00
/* more nested code */
2016-03-16 22:02:18 +03:00
2016-01-28 00:56:16 +03:00
return ret;
}
2016-03-16 22:02:18 +03:00
2016-01-28 00:56:16 +03:00
while (condition)
{
/* some code */
if (!condition)
continue;
2016-03-16 22:02:18 +03:00
2016-01-28 00:56:16 +03:00
for (i = 0; i < somevalue ; i + + )
{
if (!helperfunc (..., i, error))
goto out;
}
}