Page tree
Skip to end of metadata
Go to start of metadata

Commit message content

Writing good commit comments is critical to ensuring that changes are easily understood, even years after they were originally written. The commit comment should contain enough information about the change to allow the reader to understand the motivation for the change, what parts of the code it is affecting, and any interesting, unusual, or complex parts of the change to draw attention to.

The reason for a change may be manyfold: bug, enhancement, feature, code style, etc. so providing information about this sets the stage for understanding the change. If it is a bug, include information about what usage triggers the bug and how it manifests (error messages, assertion failure, etc). If it is a feature, include information about what improvement is being made, and how it will affect usage.

Providing some high-level information about the code path that is being modified is useful for the reader, since the files and patch fragments are not necessarily going to be listed in a sensible order in the patch. Including the important functions being modified provides a starting point for the reader to follow the logic of the change, and makes it easier to search for such changes in the future.

If the patch is based on some earlier patch, then including the git commit hash of the original patch, Jira ticket number, etc. is useful for tracking the chain of dependencies. This can be very useful if a patch is landed separately to different maintenance branches, if it is fixing a problem in a previously landed patch, or if it is being imported from an upstream kernel commit.

Having long commit comments that describe the change well is a good thing. The commit comments will be tightly associated with the code for a long time into the future, even many of the original commit comments from years earlier are still available through changes of the source code repository. In contrast, bug tracking systems come and go, and cannot be relied upon to track information about a change for extended periods of time.

Commit message format

Unlike the content of the commit message, the format is relatively easy to verify for correctness. Having the same standard format allows Git tools like git shortlog to extract information from the patches more easily.

The first line of the commit comment is the commit summary of the change. Changes submitted to the DAOS master branch require a DAOS Jira ticket number at the beginning of the commit summary. A DAOS Jira ticket is one that begins with DAOS and is therefore part of the DAOS project within Jira.  For patches to other projects, such as CaRT, a different JIRA project should be used (e.g. CART). If the patch is submitted a DAOS Jira ID in the first line, then it will automatically receive a -2 review which will prevent the patch from being submitted to a release branch. You would then need to fix the summary line and resubmit the patch.

The commit summary should also have a component: tag immediately following the Jira ticket number that indicates which DAOS subsystem that the commit is related to. Example DAOS subsystems relate to modules like: client, pool, container, object, vos, rdb; functional components like rebuild; or auxiliary components like build, tests, docs. This subsystem list is not exhaustive, but provides a good guideline for consistency.

The commit summary line must be 62 characters or less, including the Jira ticket number and component tag, so that git shortlog and git format-patch can fit the summary onto a single line. The summary must be followed by a blank like. The rest of the comments should be wrapped to 70 columns or less. This allows for the first line to be used a subject in emails, and also for the entire body to be displayed using tools like git log or git shortlog in an 80 column window.

DAOS-nnn component: short description of change under 62 columns

The "component:" should be a lower-case single-word subsystem of the
DAOS code that best encompasses the change being made.  Examples of
components include modules: client, pool, container, object, vos, rdb;
functional subsystems: recovery; and auxiliary areas: build, tests, docs.
This list is not exhaustive, but is a guideline.

The commit comment should contain a detailed explanation of changes
being made.  This can be as long as you'd like.  Please give details
of what problem was solved (including error messages or problems that
were seen), a good high-level description of how it was solved, and
which parts of the code were changed (including important functions
that were changed, if this is useful to understand the patch, and
for easier searching).  Wrap lines at/under 70 columns.

Signed-off-by: Your Real Name <your_email@domain.name>
Change-Id: Ixxxx(added automatically if missing)xxxx

The Signed-off-by: line

The Signed-off-by: line asserts that you have permission to contribute the code to the project according to the Developer's Certificate of Origin.

The Change-Id: line and Code Style

Gerrit needs to automatically identify updates to existing patches and update the existing change instead of creating a new one for each patch submitted. This preserves the history of patch comments, and allows comparing old and new versions of a patch for more efficient inspections. For this to work properly the changes you create locally need to have a unique commit id in them. The same Change-Id: line should be used for all versions of a patch.

Please make sure the Change-Id: line and Signed-off-by: lines are at the bottom of the comment. This is required for the patch to be approved. If your comments are missing either of these lines the patch will be automatically be rejected at submission time.

The Change-Id: field is inserted automatically into the commit message by installing the commit-msg hook into each Git repository's .git/hooks/ directory. To install the hook, copy it from Gerrit’s daemon by executing one of the following commands while being in the root directory of the local Git repository:

$ curl -Lo .git/hooks/commit-msg http://review.hpdd.intel.com/tools/hooks/commit-msg

Then ensure that the execute bit is set on the hook script:

$ chmod u+x .git/hooks/commit-msg

After the commit message has been saved, the commit-msg script will verify that the commit message format matches the format specified above, and insert the Change-Id: field into the commit message, if one isn't already present.

Additional commit tags

A number of additional commit tags can be used to further explain who has contributed to the patch, and for tracking purposes. These tags are commonly used with Linux kernel patches. These tags should appear before the Signed-off-by: tag.

Acked-by: User Name <user@domain.com>
Tested-by: User Name <user@domain.com>
Reported-by: User Name <user@domain.com>
Reviewed-by: User Name <user@domain.com>
CC: User Name <user@domain.com>
{Organization}-bug-id: arbitrary bug tracking identifier

The {Organization}-bug-id: tag can be used to track this patch in other bug databases.

Patches should include the Reviewed-on:permalink URL for the Gerrit patch, in the form https://review.hpdd.intel.com/nnnnn.

  • No labels