Most Free Software projects collaborate with external contributors through the use of patches and with project members through shared source control systems. Keeping a clean source control history in this case can:
- ease maintenance of the codebase (especially when merging between multiple active branches) and
- facilitate collaboration with other developers who need to quickly grasp what your changes are all about.
Reduce the noise on the main branch
If you use your source control system in a traditional centralised way, make sure that the main branch has as little noise as possible:- use feature branches when developing new functionality (i.e. use one branch per feature)
- rebase into a small number of commits instead of merging directly into the main branch (or use something like git cherry-pick -n on your commits)
Make each commit a logical unit
Ideally, the main branch should be fully usable at any point in its history. For example, if a refactoring commit breaks an existing feature, it should also include any necessary fixes. Progress and fixup commits belong to private branches and should be cleaned up before the code is published on a public repository.A commit shouldn't be too small, but at the same time, it shouldn't be too large. Before pushing a large commit, ask yourself whether or not it could be broken down into smaller or more meaningful units. Introducing a new feature through a number of smaller self-contained units often makes a branch's history much more readable.
Write meaningful commit messages
A commit message will typically be seen along with its patch. Therefore the ideal commit message will include everything which is not immediatly obvious from the code changes:- A short description of the new feature it introduces (or how to reproduce the bug it fixes)
- Links to related commits (e.g. "Fix bug introduced in COMMIT_ID")
- Bug numbers related to this commit
- The main area of the code (or subsystem) that this commit touches (as part of the short description, so that it's easily grepable)
Good commits and useful source control histories are great ways of documenting your code. If there are other conventions or practices you've found useful in your use of source control systems, please leave a comment!commit 4869fdea77052c480c54b9e66a927ba036eab29e
Author: Mikulas Patocka
Date: Mon Jun 22 10:08:02 2009 +0100
dm mpath: validate table argument count
commit 0e0497c0c017664994819f4602dc07fd95896c52 upstream.
The parser reads the argument count as a number but doesn't check that
sufficient arguments are supplied. This command triggers the bug:
dmsetup create mpath --table "0 `blockdev --getsize /dev/mapper/cr0`
multipath 0 0 2 1 round-robin 1000 0 1 1 /dev/mapper/cr0
round-robin 0 1 1 /dev/mapper/cr1 1000"
kernel BUG at drivers/md/dm-mpath.c:530!


0 comments:
Post a Comment