Difference between revisions of "Creating a Samba patch series"

(include common page with a good git commit message)
(What not to do)
Line 34: Line 34:
  
 
This request contains '''47''' commits, the merge request title does not explain what the code change is doing, and the final result is a single line code change!
 
This request contains '''47''' commits, the merge request title does not explain what the code change is doing, and the final result is a single line code change!
 +
 +
Assuming the cumulative code change listed here is what was intended (which isn't at all obvious from the merge request title), these 47 commits should have been rebased into a single commit, and likely a test should have been written to test the change.
  
 
=== A good example ===
 
=== A good example ===

Revision as of 19:54, 18 June 2020

Introduction

When contributing to Samba, there are quality expectations that need to be met in order for your patches to be accepted. Please review these guidelines before writing your first commits, otherwise you may need to rebase your patches.

This page is not meant to be a technical overview about using git, there are already plenty of resources for learning to use git. It's expected when you reach this page that you already know these concepts.

What a commit should include

Each git commit should be succinct and only do one thing. Each new feature or bug fix should include a second commit containing a test to validate the change.

A good commit message

Good commit messages are very important. Commits should always be separated in meaningful pieces. Please make sure that your commit messages include at least the following information:

Example:

s3:smbd: Add new funky shiny and groovy feature

The funky shiny and groovy feature has been added to
be able to do whatever you like. A typical usecase is the
following.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=1

Signed-off-by: Author <author@example.org>

Bisectability

The problem with merge requests is that the Changes view shows a complete product, without intermediate stages. In Samba, we also care about the history when getting to the final product. Small succinct commits make it possible to run git bisect on the history, allowing us to find commits that introduce bugs.

Sometimes developers will argue that reviewers should take the end result as a whole, and evaluate a patch series on it's functionality. We recognize the effort put into preparing patches for Samba, but requests cannot be accepted that are not bisectable.

Effective Review

It is the submitter's responsibility to make the most of code review. The reviewer will likely only point out a single instance of any given problem. The submitter is expected to find every instance of this mistake and fix it throughout the code.

Examples

What not to do

Here is an actual example from an open source project (identifying information has been removed), of a poorly created merge request:

Github mr 1.png

Github mr 2.png

This request contains 47 commits, the merge request title does not explain what the code change is doing, and the final result is a single line code change!

Assuming the cumulative code change listed here is what was intended (which isn't at all obvious from the merge request title), these 47 commits should have been rebased into a single commit, and likely a test should have been written to test the change.

A good example

Here is an example of a Samba merge request which was created correctly:

Gitlab-mr-1.png

Gitlab-mr-2.png

This request only has 2 commits, the first commit being the bug fix, and the second commit containing tests for the issue. The merge request title is very specific, mentioning the component being patched, the function name being patched, and explaining very briefly what was fixed. The patch contents only modify the single thing being fixed (excluding the tests).