set callbacks just before fetch, clear them after (fixes #403).
Add some tests for refcounts to check for leaks
Hard-code callback version because we'll need to change the defs if it changes.
Don't test refcounts in pypy as they don't make sense there
Fix use of skipIf.
Clear up confusion regarding accepted types for Repository.checkout() refname parameter
Add note about checkout('HEAD') being identical to checkout_head()
Add note about default behaviour of Repository.listall_branches()
Add note about including remote name when looking up remote branch
Allow objects of type Branch to be passed to Repository.checkout()

Branch inherits from Reference, so there's no reason why we shouldn't be
able to pass a Branch object.
Clarify return types from Repository.{create,lookup}_branch()
Add test for checking out local branches with a Branch object.

This differs from the only other test which uses a Reference object.
This test only succeeds because of the previous commit.
Fix cloning a repository with a particular branch to checkout

We were missing a cast to bytes. Add a test for this option as well and
remove the old commented-out test for checkout_branch, which is
superseded by this one and whose last bit seemed confused about what the
option means.

This fixes #399
Ensure self handle stays alive - keeping it in callbacks is not enough.
Merge remote-tracking branch 'mduggan/remote-refcount-fix'
Merge remote-tracking branch 'carlos/checkout-branch'
Merge remote-tracking branch 'djmattyg007/branches_are_references'
Merge remote-tracking branch 'djmattyg007/doc_fixes'