Table of Contents

# Git Best Practices #

This document provides advice and guidance on using and contributing to the Enlightenment Project git repositories. Please read through this document before providing pull requests, patches, or working on a repository for the first time.

A web interface to the Enlightenment Foundation repositories is available at [git.enlightenment.org](https://git.enlightenment.org/).

## Prerequisites ##

You will require ``git`` to be installed. Linux distributions using the ``apt`` package manager can install this prerequisite with the following command:

``` sudo apt install git ```

You are also expected to already possess a working knowledge of git; for more information see the [Git User Manual](https://git-scm.com/docs/user-manual.html). You should also have read the [Coding Conventions guide](https://www.enlightenment.org/contrib/devs/coding-conventions.md) before writing any code destined for submission.

## Submitting and Reviewing Patches ##

Use [https://git.enlightenment.org](Gitea) to fork a repository and create pull requests for changes on the original.

## Rebase Instead of Merge ##

Ensure that you have git set to rebase, rather than merge, by running the following command against your copy of the Enlightenment repository.

``` $ git config branch.master.rebase true ```

You can also make this configuration globally, but be aware this applies to all git repositories you access:

``` $ git config –global branch.master.rebase true ```

## Git + SSH ##

Due to a bug in the Go SSH implementation used by [Gitea](https://git.enlightenment.org), you may have to add this to your ~/.ssh/config file:

``` host git.enlightenment.org

   HostKeyAlgorithms +ssh-rsa
   PubkeyAcceptedAlgorithms +ssh-rsa

```

## Commit Messages ##

Commit messages should be detailed rather than terse and include as much information about the commit as is reasonable. Please use the imperative form in the commit message in order to be consistent with the commit messages generated by git merge and revert. Write “Fix text bug”, rather than “Fixed text bug”.

### Message Layout ###

The general layout of a commit message should be as follows:

* Line 1: {Module or Working Area}: A brief/short description of why the change has been made. This should be a single line with a maximum of 76 characters - like a NEWS entry. * Line 2: Leave this line empty. * Line 3+: The body text with a detailed description of the change. Explain why and how you have changed or fixed something in as much details as possible. Wrap lines at 76 characters.

### Message Tags ###

Depending on the nature of your commit some of the following tags might apply:

* @fix - To be used when you fixed a bug which also applies to a released version (i.e. is not exclusively code from this development cycle). This tag is used as a marker for backports, although commits can be tagged as @fix but not backported if the backport is too “dangerous” to be in the stable branch - for example a fix that required some core rewrites. * @feature - To be used when your commit introduces a new feature. Make sure your summary line is in really good shape and descriptive as this will be used in the NEWS file for the release. If this change consists of more than one commit only put it once - or, better yet, put it in the merge commit. * CID: XXXXX - To be used if you fixed a issue discovered by a Coverity scan. It gives credit to them and helps us to see which commit relates to which issue.

All these tags should live in the commit body with the detailed description, and not in the summary line. It is preferred if the tags are added as a separate line at the end of the commit message, though they will function from anywhere in the commit body.

### Simple Message Example ###

``` spinner: Uncomment ctype.h inclusion because isspace is used.

It looks like ctype.h is included in some other headers by luck but it is recommended to explicitly include the necessary header. Confirmed by glima as he commented this out. ```

### Feature Addition Message Example ###

``` eina: Add purple/yellow cherry tree algorithm implementation

Newest research shows that the purple/yellow cherry tree algo is way more efficient memory wise. Add a implementation to eina so we can try it out in the real world. @feature ```

### Bug Fix Message Example ###

``` evas textblock: Fix buffer overflow in anchor code

If we set the anchor on a long text block the buffer might overflow. Take string len into account. Long-standing bug. @fix CID: 123456 ```

## Merging Changes Back into Master ##

Use cherry-pick for small changes if you don't want to push everything into master. If you did work into your own branch and worked on some big feature then you should push to master using the following workflow:

1. Create a branch, either local or remote, for your change. 2. Work on that branch. 3. When ready, instead of pushing to master, rebase over master: ``git fetch; git rebase -p origin/master``. 4. If the commit history does not follow the [Commit Message guidelines](#Commit_Messages) ``rebase interactive`` to make sure all your pending patch notes are meaningful; merge them and change their commit messages as necessary. 6. Switch to master: ``git checkout master`` 7. ``git merge –no-ff your-feature-branch-name`` 8. Describe your feature in the commit message. 9. Push to master using ``git push`` or ``git push origin master``.

## Further Reading ## [git.enlightenment.org](https://git.enlightenment.org/) : A web interface to the Enlightenment git repositories.

[git+help@lists.enlightenment.org](mailto:git+help@lists.enlightenment.org) : The mailing list for git assistance requests.

[wiki.openstack.org/wiki/GitCommitMessages#Summary_of_Git_commit_message_structure](https://wiki.openstack.org/wiki/GitCommitMessages#Summary_of_Git_commit_message_structure) : The Openstack Project's guide to what information should be in a commit message.

[who-t.blogspot.de/2009/12/on-commit-messages.html](http://who-t.blogspot.de/2009/12/on-commit-messages.html) : Peter Hutterer's guide to good commit messages.

[wiki.videolan.org/Git](https://wiki.videolan.org/Git) : The VideoLAN Project uses the same workflow as the Enlightenment Project.

[Coding Conventions](https://www.enlightenment.org/contrib/devs/coding-conventions.md) : Rules to which code submitted to the Enlightenment Project must adhere.