Merge pull request #1222 from scunz/clone_branch

Switch to specified branch during clone
Added flag GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE to test_repo_init__extended_with_template().

Otherwise the template functionallity is not tested (as a TODO we
also shall test that the specified template really got copied).
indexer: properly free the packfile resources

The indexer needs to call the packfile's free function so it takes care of
freeing the caches.

We still need to close the mwf descriptor manually so we can rename the
packfile into its final name on Windows.
tests: plug leaks
pack: fixes to the cache

The offset should be git_off_t, and we should check the return value
of the mutex lock function.
Clear local error variable after invoking giterr_clear().
add an index_remove_bypath that removes conflicts, renamed add_from_workdir to match
checkout: Teach checkout to cope with orphaned Head

Fix #1236
Fix Travis compilation warnings
Do not use GIT_CPDIR_CHMOD flag when copying the template.

This is an intermin solution. While this essentially disables the
--shared flag feature, previously external templates did not work
at all. This change fixes the previously corrected, and since
then failing, repo_init__extended_with_template() test.

The problem is now documented in the source code comments.
Now checks in the template test whether the description file has
been properly copied.

This is a minimal effort to test whether the template really has
been used when creating an repo with external templates.
Altered the description of the template.

Before, it was identical to the default template making it difficult
to check, if the proper template was copied an external template
test.
pack: evict objects from the cache in groups of eight

This drops the cache eviction below libcrypto and zlib in the perf
output. The number has been chosen empirically.
pack: evict all of the pages at once

Somewhat surprisingly, this can increase the speed considerably, as we
don't bother trying to decide what to evict, and the most used entries
are quickly back into the cache.
Merge pull request #1242 from sba1/init-with-template-fix

Some fixes for external template support
Merge pull request #1238 from nulltoken/fix/checkout-index

checkout: Teach checkout to cope with orphaned Head
status: Enhance git_status_file() test coverage
Simplify git_diff__paired_foreach icase handling
Minor iterator API cleanups

In preparation for further iterator changes, this cleans up a few
small things in the iterator API:

* removed the git_iterator_for_repo_index_range API
* made git_iterator_free not be inlined
* minor param name and test function name tweaks
Fix err msg for ambiguous path in git_status_file

Returning GIT_EAMBIGUOUS from inside the status callback gets
overridden with GIT_EUSER.  `git_status_file` accounted for this
via the callback payload, but was allowing the error message to
be cleared.  Move the `giterr_set` call outside the callback to
where the EUSER case was being dealt with.