Coding style/Version control practices
The content on this page has not been reviewed and does not reflect the policy of the development team (yet). Also, the instructions about RT headers rely on a change to rt-cvsgate which has not yet been deployed.
The material on this page applies to developers with commit access to our master repository, or to contributors preparing contributions using a github fork.
Contents
Commit messages
Begin each commit message with a summary line of less than 50 characters, capitalized but with no trailing period. Think of this line like you would the subject of an email message. The summary should make sense without knowing what files are touched by the commit. Good summary lines make it easier to find commits in a gitk, github, or "git log --oneline" summary of commits.
If the change in the commit is not trivial, follow the summary line with a blank line and a longer description of the change. Do not explain every detail of the change, and do not use the commit message as a substitute for documenting the code. Instead, focus on explaining the motivation behind the change. Wrap lines at 70 characters. Here is an example:
Make krb5_check_clockskew public Rename krb5int_check_clockskew to krb5_check_clockskew and make it public, in order to give kdcpreauth plugins a way to check timestamps against the configured clock skew.
RT headers
This subsection applies to committers only. Contributors can ignore it.
If a commit makes a user-visible change, such as adding a new feature or fixing a user-visible bug in a previous release, it should be associated with an RT ticket. Do this by adding RT pseudo-headers at the end of a ticket, separated by a blank line. The most important header is "ticket:", which associates the commit with a ticket number. The "subject:" header can be used to set the subject of a ticket, if it is not already set. Add "tags: pullup" and "target_version: X.Y.Z" if the commit should be pulled up to a previous branch.
(TODO: update when we determine how "ticket: new" will be handled after the git conversion. Also if we make it possible to set subjects on new tickets with the summary line.)
One logical change per commit
Do not combine several unrelated changes into a commit. Avoid the temptation to adjust nearby code formatting or re-word comments which are not related to the primary purpose of the commit. Although it's more work to split those changes out into separate commits, reviewing commits or examining history is easier when all of the changes in a commit have the same purpose.
However, it is okay to include test cases or documentation in the same commit as code changes. A bug fix could come in the same commit as a regression test for the bug, and a new feature could come in the same commit as its documentation and test cases.
Prepare a clean patch series
If you are working on a medium or large change which naturally breaks down into multiple logical changes, rewrite the history of your branch so that each commit makes one logical change and there are no development artifacts. For example, here are the summary lines of some recent ASN.1 work which was prepared as a patch series (most recent to least recent):
Remove unneeded ASN.1 code Convert utility functions to new decoder Data-driven ASN.1 decoder Change optional handling in ASN.1 encoder Style and naming changes to ASN.1 encoder Use size_t for lengths in ASN.1 encoder Minimize draft9 PKINIT code by removing dead code Eliminate some unused ASN.1 encoding primitives Fold atype_primitive into atype_fn Simplify ASN.1 choice type definitions Add ASN.1 decoder test for krb5_pa_pac_req
The team will not want to review a branch which looks like:
Add comments Refactor and cleanup Oops, add export symbols for client support Add server support Merge from trunk Rename frobnitz to whizzbang Add client support
You can use "git rebase -i" to cleanup a patch series; for a more advanced toolset, consider trying out Stacked Git.