Turn headings into actual links
[openafs-wiki.git] / GitDevelopers.mdwn
index 34b9ffb..f0dd0c0 100644 (file)
@@ -1,14 +1,26 @@
-Git opens up a number of new options for contributing to OpenAFS. For the first time, it is easy to review code that is pending addition to the OpenAFS tree. In fact, reviewing code is one of the best ways to ensure that the releases that OpenAFS ships remain stable and functional. If you are interested purely in reviewing, then please skip to that section towards the end of this document .
-
-Git also changes the way that developers interact with the OpenAFS tree. Instead of just having a single version of the tree on your local machine, you have a compressed copy of the entire repository. Additionally, you no longer have to produce patches to send code upstream - any developer can push into the OpenAFS repository directly, through gerrit, our code review tool.
-
-Whilst git is a far more powerful tool than CVS it is also, inevitably, more complex. This document can only scratch the surface of what's possible with git - there are many, many, documents available that describe git in greater detail, and references to some of them are provided at the end.
-
-## <a name="Getting git"></a> Getting git
+Git opens up a number of new options for contributing to OpenAFS. For the first
+time, it is easy to review code that is pending addition to the OpenAFS tree.
+In fact, reviewing code is one of the best ways to ensure that the releases
+that OpenAFS ships remain stable and functional. If you are interested purely
+in reviewing, then please skip to that section towards the end of this
+document.
+
+Git also changes the way that developers interact with the OpenAFS tree.
+Instead of just having a single version of the tree on your local machine, you
+have a compressed copy of the entire repository. Additionally, you no longer
+have to produce patches to send code upstream - any developer can push into the
+OpenAFS repository directly, through gerrit, our code review tool.
+
+Whilst git is a far more powerful tool than CVS it is also, inevitably, more
+complex. This document can only scratch the surface of what's possible with git
+- there are many, many, documents available that describe git in greater
+detail, and references to some of them are provided at the end.
+
+## <a name="Getting git">Getting git</a>
 
 Firstly, if your machine doesn't already have it installed, get a copy of the 'git' version control system. This is available for many platforms from their upstream package repositories or, failing that, can be downloaded in both source and binary form from 
 
-## <a name="Getting the _OpenAFS repository"></a> Getting the OpenAFS repository 
+## <a name="Getting the _OpenAFS repository">Getting the OpenAFS repository</a>
 
 You can download the entire OpenAFS repository by running
 
@@ -22,7 +34,7 @@ to place your clone in a specific directory
 
 This will give you a complete copy of the OpenAFS repository and unless you are exceptionally short of either disk space, or time, is the approach we recommend. Unlike CVS, you are not just checking out a particular branch, but making a local copy of the project's whole revision history, across all of it's branches. This does make the download pretty large - around 150Mbytes at the time of writing.
 
-## <a name="Updating the local copy"></a> Updating the local copy
+## <a name="Updating the local copy">Updating the local copy</a>
 
 When you want to update the local repository with the central OpenAFS one, running
 
@@ -30,7 +42,7 @@ When you want to update the local repository with the central OpenAFS one, runni
 
 will pull all of the new changes into your local repository, and merge those changes into your current working tree. Note that whilst this is fine when you are browsing the repository, you may want to exercise more control over how upstream changes are merged into your development code.
 
-## <a name="Checkout a particular branch"></a> Checkout a particular branch
+## <a name="Checkout a particular branch">Checkout a particular branch</a>
 
 The OpenAFS repository contains many branches, most of which are historical and should not be used for new development. Current development should be targetted at 'master' (for feature work, and general bugfixing), or at 'openafs-stable-1\_4\_x' (bug fixes specific to the current stable release). Note that the openafs-devel-1\_5\_x branch is now effectively dead - future 1.5 releases will occur from the 'master' branch.
 
@@ -56,7 +68,7 @@ or, more simply
 
 or by creating a topic branch as discussed below.
 
-## <a name="Checkout a particular release"></a> Checkout a particular release
+## <a name="Checkout a particular release">Checkout a particular release</a>
 
 Every release version of [[OpenAFS]] is marked in the repository by means of a tag.
 
@@ -68,11 +80,25 @@ To checkout a particular tag
 
     git checkout openafs-stable-1_4_10
 
-Again, whilst a direct checkout of a remote tag is fine for code browsing, it should not be used as a place to start development. If you must do development against a tag, then create a local topic branch with it as a starting point, as is discussed below. However, in general, please don't develop from a particular tag, but instead work from a branch tip. It makes it much easier to integrate your changes!
-
-## <a name="Viewing deltas"></a> Viewing deltas
-
-OpenAFS's original CVS repository used the concept of deltas as a means of grouping a large number of related changes into a single item, which could be easily fetched and referred to. In git, a delta should be simply a single commit. Deltas are represented by means of a special form of git tag, allowing you to locally view the change and commit message that corresponds to each one. In order to keep down the transfer size, deltas are not included in the repository you get when you do a git clone - there are over 10,000 delta references, and having them in your local repository can cause performance issues. If you really wish to be able to locally browse deltas, then run the following
+Again, whilst a direct checkout of a remote tag is fine for code browsing, it
+should not be used as a place to start development. If you must do development
+against a tag, then create a local topic branch with it as a starting point, as
+is discussed below. However, in general, please don't develop from a particular
+tag, but instead work from a branch tip. It makes it much easier to integrate
+your changes!
+
+## <a name="Viewing deltas">Viewing deltas</a>
+
+OpenAFS's original CVS repository used the concept of deltas as a means of
+grouping a large number of related changes into a single item, which could be
+easily fetched and referred to. In git, a delta should be simply a single
+commit. Deltas are represented by means of a special form of git tag, allowing
+you to locally view the change and commit message that corresponds to each one.
+In order to keep down the transfer size, deltas are not included in the
+repository you get when you do a git clone - there are over 10,000 delta
+references, and having them in your local repository can cause performance
+issues. If you really wish to be able to locally browse deltas, then run the
+following
 
     git config --add remote.origin.fetch '+refs/deltas/*:refs/remotes/deltas/*'
     git fetch origin
@@ -81,11 +107,17 @@ You can then view a specific delta by doing
 
     git show refs/remotes/deltas/<branch>/<delta>
 
-Sadly, historical accidents mean that not all of our deltas can be represented by means of single commit. Where this is the case, a delta-name will have a trailing -part-, where each of these numbers must be used to form the complete delta. This only applies to some deltas created before the git conversion - all deltas created from now on will be single commits.
+Sadly, historical accidents mean that not all of our deltas can be represented
+by means of single commit. Where this is the case, a delta-name will have a
+trailing -part-, where each of these numbers must be used to form the complete
+delta. This only applies to some deltas created before the git conversion - all
+deltas created from now on will be single commits.
 
-## <a name="Introducing yourself to git"></a> Introducing yourself to git
+## <a name="Introducing yourself to git">Introducing yourself to git</a>
 
-Before you begin development, you should let git know who you are. This provides it with a name, and email address, that is used to attribute all commits in your repository, and in any that you share code with.
+Before you begin development, you should let git know who you are. This
+provides it with a name, and email address, that is used to attribute all
+commits in your repository, and in any that you share code with.
 
     git config user.name "Joe Bloggs"
     git config user.email "joe.bloggs@example.org"
@@ -95,11 +127,18 @@ If you want to make this settings for all of your repositories, then add the --g
     git config --global user.name "Joe Bloggs"
     git config --global user.email "joe.bloggs@example.org"
 
-Note that this email address is the address by which you will be identified in [[OpenAFS]]'s revision history - it is also the address to which the gerrit code review tool will send all email related to the review of your code.
+Note that this email address is the address by which you will be identified in
+[[OpenAFS]]'s revision history - it is also the address to which the gerrit
+code review tool will send all email related to the review of your code.
 
-If you plan on making changes to OpenAFS (and why else would you be reading this?) you should probably also grab <b>The change id hook</b> described in <b>Registering With gerrit</b> below. You can grab and apply the hook before registering, and it'll make sure your pre-registration development has the appropriate change IDs in the log. The hook only applies to your openafs development, so you're not going to mess up any of your non-OpenAFS work.
+If you plan on making changes to OpenAFS (and why else would you be reading
+this?) you should probably also grab <b>The change id hook</b> described in
+<b>Registering With gerrit</b> below. You can grab and apply the hook before
+registering, and it'll make sure your pre-registration development has the
+appropriate change IDs in the log. The hook only applies to your openafs
+development, so you're not going to mess up any of your non-OpenAFS work.
 
-## <a name="Helpful git tips"></a> Helpful git tips
+## <a name="Helpful git tips">Helpful git tips</a>
 
 Here are a few other git settings that may be helpful when working with the source.
 
@@ -117,9 +156,11 @@ Whitespace handling settings:
     git config core.whitespace trailing-space,space-before-tab,indent-with-non-tab
     git config config.cleanup whitespace
 
-## <a name="Starting development"></a> Starting development
+## <a name="Starting development">Starting development</a>
 
-We strongly recommend that you do all of your development upon 'topic branches' This allows you to isolate multiple unrelated changes, and makes it easier to keep your tree in sync with the upstream [[OpenAFS]] one.
+We strongly recommend that you do all of your development upon 'topic branches'
+This allows you to isolate multiple unrelated changes, and makes it easier to
+keep your tree in sync with the upstream [[OpenAFS]] one.
 
 Before creating a new topic branch, running
 
@@ -143,7 +184,7 @@ This puts me on a new branch, ready to start writing code. All new development s
 
 'git commit -a' is used to commit code to all of the files that git is currently tracking (that is, all of the files that you have checked out from the repository, and all those which you have run git add on)
 
-## <a name="When you can&#39;t see the wood for"></a><a name="When you can&#39;t see the wood for "></a> When you can't see the wood for the trees
+## <a name="When you can&#39;t see the wood for">When you can't see the wood for the trees</a>
 
 If, in the middle of development, you discover that you've gone down a blind alley, and wish to go back to the state of your last commit
 
@@ -155,7 +196,7 @@ will discard all of the changes you have made since the last commit, or
 
 will restore &lt;file&gt; to the state it was in at the last commit.
 
-## <a name="Keeping up with the Jones&#39;"></a> Keeping up with the Joneses
+## <a name="Keeping up with the Jones&#39;">Keeping up with the Joneses</a>
 
 If you're working on a long running development project, you will find that the point your created your topic branch rapidly recedes into history. At some point (and at least before you share your code with us), you'll probably want to update your tree. There are a number of ways of doing this.
 
@@ -169,7 +210,7 @@ Note that git rebase changes your local history (it moves the branch point of yo
 
 If you can't rebase, then consider either merging the changes onto your local branch, or creating a new topic branch and cherry picking your changes onto it. The man pages for 'git merge' and 'git cherry-pick' provide more detail on these options.
 
-## <a name="Sharing your code with us"></a> Sharing your code with us
+## <a name="Sharing your code with us">Sharing your code with us</a>
 
 How you work from this point onwards depends on how you intend making your code available to OpenAFS. We're still happy to receive submission by patch (by sending your changes to <openafs-bugs@openafs.org>), but it makes it much easier for us if you push directly from your git tree to our code review system, gerrit.
 
@@ -198,7 +239,7 @@ To make things easier, set up OpenSSH so that it knows about the defaults for th
 
 (where Username is the username you noted down from the 'Profile' page)
 
-### <a name="The change id hook"></a> The change id hook
+### <a name="The change id hook">The change id hook</a>
 
 Gerrit introduces the concept of "change IDs". This is a unique reference for a particular change, which remains constant regardless of any changes that are made to the implementation. This allows a single reference to be attached to a given modification, irrespective of any rewrites that may occur as a result of review comments. Manually maintaining change Ids is a pain, so gerrit provides a git hook which can be used to automatically add a change Id to any new modifications you create.
 
@@ -206,13 +247,13 @@ The hook should be downloaded from the [[OpenAFS]] gerrit server by running the
 
     scp -p -P 29418 gerrit.openafs.org:hooks/commit-msg .git/hooks/
 
-## <a name="Uploading to gerrit"></a> Uploading to gerrit
+## <a name="Uploading to gerrit">Uploading to gerrit</a> 
 
 When submitting to gerrit, it's important to realise that each commit in your branch will become a changeset in the upstream OpenAFS, typically with no modification at our end. It is therefore important that these commits follow some simple rules...
 
 First, each commit should be complete. The maxim "one change per commit, one commit per change" applies here. Each commit should build and test in its own right. Typically, this means that a change will be in a small number of commits. If, during development, you have created many more than this (for example, you've created a large number of bug fix commits), please use 'git rebase', or cherry pick these commits into a separate tree before uploading them.  Note, however, that "one change" could equate to a change to source code and a change to the corresponding documentation for that code specific change.
 
-Secondly, each commit should have a meaningful revision log. The internals of git means that we can't easily edit these before pushing them into the tree, so we'd like you to get them right for us! A commit message should be comprised of a single 'subject' line (which must **not** end with a full stop), followed by a blank line, followed by one or more paragraphs explaining the purpose of the patch. If it is intended to fix a bug in OpenAFS RT, then the word 'FIXES' followed by the bug number or comma-separated list of bug numbers should be included on a line of its own. The 'LICENSE' keyword can be used to indicate code which is covered under a license other than the IPL, although please speak to a gatekeeper if you intend using this. An example commit message would be
+Secondly, each commit should have a meaningful revision log. The internals of git means that we can't easily edit these before pushing them into the tree, so we'd like you to get them right for us! A commit message should be comprised of a single 'subject' line (which must **not** end with a full stop), followed by a blank line, followed by one or more paragraphs explaining the purpose of the patch. Gerrit warns if the 'subject' is longer than 65 characters. If it is intended to fix a bug in OpenAFS RT, then the word 'FIXES' followed by the bug number or comma-separated list of bug numbers should be included on a line of its own. The 'LICENSE' keyword can be used to indicate code which is covered under a license other than the IPL, although please speak to a gatekeeper if you intend using this. An example commit message would be
 
       Add option to disable syscall probing
 
@@ -226,8 +267,6 @@ Secondly, each commit should have a meaningful revision log. The internals of gi
 
 Thirdly, each commit should have a valid changeID. Manually maintaining these is difficult and error prone, so we would strong advise that you install the changeID hook detailed earlier. This will automatically add a [[ChangeId]] line to your commit message if it doesn't already contain one.
 
-Pour sécuriser efficacement les archives et documents papiers importants, l'idéal est d'utiliser une bonne [armoire forte réfractaire](http://www.infosafe.fr/Armoirefortedin/Armoirefortedin.htm) fixée au sol.
-
 Fourthly, each commit must adhere to the OpenAFS whitespace policy whereby new commits will not be accepted if they have trailing spaces, spaces before tabs, or indentation without tabs.  Git can be configured to highlight the whitespace policy violation with the following global setting:
 
     git config --global core.whitespace trailing-space,space-before-tab,indent-with-non-tab
@@ -240,6 +279,12 @@ can be used to automatically fix any policy violations on your local branch befo
 
     git config --global config.cleanup whitespace
 
+Then commit your changes, for example with a file that contains your log message
+
+    git commit -a -F <your-log-message-in-this-file>
+
+(where &lt;your-log-message-in-this-file&gt; is a file with the log message)
+
 Once your commits have a proper commit message and have all whitespace errors fixed, use
 
     git log -p origin/<branch>..HEAD
@@ -262,11 +307,9 @@ Although, it would be sufficient to simply issue the command as:
 
 This relies upon the ssh configuration you performed earlier. If it fails to work, please consult the troubleshooting notes at <http://gerrit.googlecode.com/svn/documentation/2.0/user-upload.html>
 
-Pour sécuriser efficacement les archives et documents papiers importants, l'idéal est d'utiliser une bonne [armoire forte réfractaire](http://www.infosafe.fr/Armoirefortedin/Armoirefortedin.htm) fixée au sol
-
 Assuming all has gone well, this will have added the entry to the code review queue. The output from git review will give you a change number - this is a unique reference for this particular set of changes. During review you'll be emailed with any comments anyone makes, and can respond to those comments using the gerrit web interface (see the section on reviewing, below). It's possible that issues with your change may be noticed during the review process, and you may be asked to revise it, or update changes to the tip of the tree.
 
-## <a name="Revising your change"></a> Revising your change
+## <a name="Revising your change">Revising your change</a> 
 
 It's possible that your modifications won't be accepted first time. In this case, you need to revise your changes, and resubmit them to gerrit. Please note that this should always be done by modifying your original changeset, _not_ by submitting a new change that makes the required fixes. Either git commit -a --amend, or git rebase should be used to combine your changes with the original changeset, and then you should push this to gerrit with
 
@@ -274,7 +317,7 @@ It's possible that your modifications won't be accepted first time. In this case
  
 where &lt;revision&gt; is the SHA-1 hash of the revised change that follows the word <tt>commit</tt> in the log message, or simply <tt>HEAD</tt> if the revised change is the most recent change on your topic branch.  You can obtain the SHA-1 hash of a commit by using 'git log'.  Note that pushing to <tt>refs/for/...</tt> _requires_ a change-id in your commit message, so that Gerrit can match to the new change with the one you submitted previously.  See <http://gerrit.googlecode.com/svn/documentation/2.0/user-upload.html> for full details.
 
-## <a name="Updating your change"></a> Updating your change
+## <a name="Updating your change">Updating your change</a> 
 
 It's possible that your change may have been made against a tree which is too old for it to apply to the tip. In this case, gerrit will let you know that there is a collision, and request that you update the change to the tip.
 
@@ -290,6 +333,68 @@ When a rebase is performed there may be conflicts that cannot be automatically r
 
 After you have resolved all conflicts and are once again happy with the commit, simply resubmit your change in the same way as if you had been asked to revise it (see notes above)
 
+## <a name="Pulling up a change to a stable branch">Pulling Up a Change to a Stable Branch</a> 
+
+After a change has passed through the Gerrit Code Review process it will be merged onto the <tt>master</tt> branch of the OpenAFS repository.  The merged commit will then become visible in your local repository the next time a 
+
+    git pull
+
+command is executed.  OpenAFS releases are not issued from the <tt>master</tt> branch.  Instead releases such as <tt>1.6.11</tt> are issued from stable branches such as <tt>openafs-stable-1_6_x</tt>.  After a change is approved on <tt>master</tt> the change must be pulled up to the stable branch, be modified for any differences between <tt>master</tt> and <tt>openafs-stable-N_N_x</tt> and be resubmitted to Gerrit.
+
+Start by checking out the stable branch of interest.  For example, if you want to submit a change to the next 1.6 series release you would first checkout <tt>master</tt>.
+
+    git checkout --track origin/master
+
+or just
+
+    git checkout master
+
+if you have already created the tracking branch.  Then
+
+    git pull
+
+to import any new changes to the local repository and fast-forward <tt>HEAD</tt> to the most recent commit merged onto <tt>origin/master</tt>.   It is important to note that if any local changes were committed onto the local <tt>master</tt> tracking branch that a fast-forward operation will not occur.  Instead the local changes and the changes to origin will be merged producing a merge commit.  A merge commit is not compatible with the OpenAFS management of the git repository.   To rebase local changes onto of the <tt>HEAD</tt> of <tt>origin/master</tt> the command
+
+    git pull --rebase
+
+can be performed.  If there are conflicts when applying the local changes to current <tt>HEAD</tt> of <tt>origin/master</tt> you will have an opportunity to resolve them.
+
+Once the change you wish to pullup to the stable branch is in the local repository you can use
+
+    git log master
+
+to find it and record the sha1 identifier for the commit.   Now you are ready to switch to the stable branch for example, <tt>openafs-stable-1_6_x</tt>.   If you do not already have a local tracking branch execute
+
+    git checkout --track origin/<stable-branch>
+
+and if you do then execute
+
+    git checkout <stable-branch>
+
+After switching branches you might be told that the local branch is behind the <tt>origin</tt>.  If so, execute
+
+    git pull
+
+to fast-forward the branch <tt>HEAD</tt> to the most recent commit.   Now you can pull the commit from <tt>master</tt> by using performing a cherry-pick:
+
+    git cherry-pick -x <sha1>
+
+This will create a new commit on the current branch with a commit message that has been modified with
+
+    (cherry picked from commit <sha1>)
+
+This commit message will include the <tt>Change-Id</tt> from the original submission to Gerrit.  It is important that the <tt>Change-Id</tt> values submitted to Gerrit be unique but Gerrit will not enforce this.  You <b>must</b> remember to edit the commit message and remove the old <tt>Change-Id</tt> using
+
+    git commit --amend
+
+so that the Change ID Hook will generate a new <tt>Change-Id</tt> before pushing the change to Gerrit.
+
+Once the commit message has been ammended and any other required changes are made it is time to push the change to Gerrit:
+
+    git push ssh://gerrit.openafs.org/openafs.git HEAD:refs/for/<stable-branch>/<topic>
+
+The change will then be evaluated by the OpenAFS Release team for incorporation into a future stable release.
+
 ## <a name="Submitting by patch"></a> Submitting by patch
 
 If all of this seems too daunting (and please don't let it put you off) you can still, of course, submit patches by email.
@@ -310,7 +415,7 @@ For each commit on your local branch after the most recent patch on "master", a
 
 Regardless of which approach you use, you can e-mail the changes to <openafs-bugs@openafs.org> as before. Note, however, by doing this you're making someone else take the patch, create a topic branch in their local tree, apply the patch, push it into gerrit, and become responsible for managing the review process. Things would be much more efficient if you pushed into gerrit yourself. Please?
 
-## <a name="Reviewing changes"></a> Reviewing changes
+## <a name="Reviewing changes">Reviewing changes</a> 
 
 We'll now look at how changes that have made it into gerrit can be reviewed. All code review now happens via the <http://gerrit.openafs.org> interface. You should log in there as detailed above (using any OpenID), and make sure that the email address points to somewhere you'll read regularly.
 
@@ -324,7 +429,7 @@ To verify the code, pull the git copy into your local tree, using the git comman
 
 And that's pretty much it. All of this is very new. If you encounter any problems at all, please ask for help on IRC in #openafs, Jabber in <openafs@conference.openafs.org> or on <openafs-devel@openafs.org>. Private pleas may be addressed to <simon@sxw.org.uk>
 
-## <a name="Further Reading"></a> Further Reading
+## <a name="Further Reading">Further Reading</a> 
 
 Git Magic <http://www-cs-students.stanford.edu/~blynn/gitmagic/>
 
@@ -334,9 +439,11 @@ Git Community Book <http://book.git-scm.com/>
 
 Gerrit Documentation <http://gerrit.googlecode.com/svn/documentation/2.0/index.html> (only the first 'User Guide' section of this document is relevant)
 
+
+
 Five advanced Git merge techniques <http://blog.ezyang.com/2010/01/advanced-git-merge/>
 
-## <a name="Acknowledgments"></a> Acknowledgments
+## <a name="Acknowledgments">Acknowledgments</a> 
 
 Thanks to everyone who has reviewed this document, and offered corrections and contributions.