]> git.cworth.org Git - notmuch-wiki/blobdiff - patchformatting.mdwn
Added subsection about pre-commit hook
[notmuch-wiki] / patchformatting.mdwn
index a61c41aca24d67deee34e6732a887e6124856b39..3a122fc323e690be644a0c54a0074b007546be09 100644 (file)
@@ -10,7 +10,7 @@ you should check the following:
 
 2. Read mailing list (archives) and follow the discussions on the patches sent.
 
-3. Get familiar with coding conventions used (in any particular project).
+3. Get familiar with coding conventions used.
 
 This way you get some insight of the look and feel of the patches sent,
 both the way code should be written, how to write commit log messages
@@ -33,16 +33,47 @@ Enter your commit message in following format:
 The 65-character (limit) seems to be common among many projects so
 that is good guideline to follow here too.
 
+### Activating default pre-commit hook
+
+Git provides a default pre-commit hook which, when activated, checks
+(at least) for whitespace errors (trailing whitespace and space before
+tab). It is better to notice this kind of "errors" early than have
+patch reviewers to mention about those.
+
+The hook, when activated, is named as .git/hooks/pre-commit and it
+has execute permissions set on. By default, when git tree is cloned
+your hooks dir may have default, inactive pre-commit hook available
+as:
+
+1. .git/hooks/pre-commit  without execute permission set
+
+2. .git/hooks/pre-commit.sample  usually with execute permission set
+
+In case of 2, enter `cp .git/hooks/pre-commit.sample .git/hooks/pre-commit`.
+And, now enter `chmod a+x .git/hooks/pre-commit` in case it does not
+have execute permission set.
+
 ## Remember: one patch per email
 
 Every patch should (must!) contain only one bugfix or new feature.
 
-Eric S. Raymond has written good 'Software Release Practice HOWTO'.
+Eric S. Raymond has written good 
+[Software Release Practice HOWTO](http://tldp.org/HOWTO/Software-Release-Practice-HOWTO/).
 Check what he has to say about this issue. 
 
+### Test Suite Enhancements
+
+New features as well as bug fixes should typically come with test suite
+enhancements.  The test suite changes should be done first (tagged as *expected
+to fail*), and the feature implementation or bug fix should come second
+(removing the *expected to fail* tag).  This way, the test suite specifies the
+behavior you're trying to implement, be it a new feature or a bug fix.  By
+defining beforehand exactly what you expect to happen, everyone can confirm
+that your patch achieves what it is meant it to.
+
 ## Prepare patches for e-mail submission
 
-If you're made just one commit (containing just one bugfix or new feature)
+If you've made just one commit (containing just one bugfix or new feature)
 you can run
 
       git format-patch HEAD^
@@ -71,14 +102,18 @@ If you have committed more patches, and want to prepare all of those
 you can check with `git log` a 40-char commit-sha1 of the last commit
 *since* you want to generate patch files. When you enter 
 
-      git format patch commit-sha1(-prefix)
+      git format-patch <commit-sha1(-prefix)>
 
 every commit *after* that commit-sha1 will be used to generate 
 patch files...
 
-## Using git send-email to send patches.
+## Sending patches
+
+### Using git send-email
 
-If you try to execute `git send-email` and you'll get
+(This is the preferred way)
+
+If you try to execute `git send-email` and you get
 
       git: 'send-email' is not a git command. See 'git --help'.
 
@@ -112,16 +147,20 @@ to your own email address to see how the messages appear in your mailbox.
 In this phase you can "streamline" your `git send-email` options for
 actual patch sending to the mailing list.
 
-## Sending one patch using compatible (emacs) email client.
+### Sending one patch using compatible (emacs) email client.
+
+Sometimes using git-send-email is not possible; It is not installed by
+default and you don't have privileges to install it or you are not
+able to compile it as it has more build-time requirements as git itself.
 
 One alternative way to send your patches is to use, for example, the
-emacs mail client you've already used to send mails to notmuch mailing list.
+emacs mail client you've already used to send mails to mailing list.
 In this case you have to be very careful to keep the patch contents
 unchanged:
 
 1. Start composing new mail
 
-2. Enter notmuch mailing list address to To: field.
+2. Enter notmuch mailing list address into To: field.
 
 3. Go to the body part of the email