tests: Introduce count_config_entries_match() helper
remote: Introduce git_remote_delete()
remote: move branch upstream deletion to use an iterator

This should make it more readable and allocate a bunch fewer strings.
Fix mutex init/free in config_file.c
Better search path sandboxing

There are a number of tests that modify the global or system
search paths during the tests.  This adds a helper function to
make it easier to restore those paths and makes sure that they
are getting restored in a manner that preserves test isolation.
pack: init the cache on packfile alloc

When running multithreaded, it is not enough to check for the offmap
allocation. Move the call to cache_init() to packfile allocation so we
can be sure it is always allocated free of races.

This fixes #2355.
Merge pull request #2356 from libgit2/rb/restore-search-paths

Better global search path sandboxing in tests
Merge pull request #2357 from libgit2/cmn/pack-cache-init

pack: init the cache on packfile alloc
remote: remove remote-tracking branches on delete

When we delete a remote, we also need to go through its fetch refspecs
and remove the references they create locally.
Merge pull request #2313 from libgit2/cmn/remote-delete

Remote deletion
Win32: Supply _O_NOINHERIT when calling _wopen
Merge pull request #2360 from phkelley/noinherit

Win32: Supply _O_NOINHERIT when calling _wopen
indexer: use mmap for writing

Some OSs cannot keep their ideas about file content straight when mixing
standard IO with file mapping. As we use mmap for reading from the
packfile, let's make writing to the pack file use mmap.
indexer: mmap fixes for Windows

Windows has its own ftruncate() called _chsize_s().

p_mkstemp() is changed to use p_open() so we can make sure we open for
writing; the addition of exclusive create is a good thing to do
regardless, as we want a temporary path for ourselves.

Lastly, MSVC doesn't quite know how to add two numbers if one of them is a
void pointer, so let's alias it to unsigned char.C