Version control

Commit Discipline

We follow the Git project's own commit discipline practice of "Each commit is a minimal coherent idea". This discipline takes a bit of work, but it makes it much easier for code reviewers to spot bugs, and makes the commit history a much more useful resource for developers trying to understand why the code works the way it does, which also helps a lot in preventing bugs.

Coherency requirements for any commit:

When you should be minimal:

When not to be overly minimal:

Other considerations:

Zulip expects you to structure the commits in your pull requests to form a clean history before we will merge them; it's best to write your commits following these guidelines in the first place, but if you don't, you can always fix your history using git rebase -i.

It can take some practice to get used to writing your commits with a clean history so that you don't spend much time doing interactive rebases. For example, often you'll start adding a feature, and discover you need to a refactoring partway through writing the feature. When that happens, we recommend stashing your partial feature, do the refactoring, commit it, and then finish implementing your feature.

Commit Messages

First, check out these examples of commits with good commit messages. There are a few mistakes we see often that make commit messages less useful than they could be.

Good:

gather_subscriptions: Fix exception handling bad input.
zjsunit: Fix running stream_data and node tests individually.
Add GitLab integration.

Bad:

bugfix
gather_subscriptions was broken
fixing exception when given bad input
fix bug #234.

Bad:

gather_subscriptions: Fixing exception when given bad input.
gather_subscriptions: Fixed exception when given bad input.