config: don't allow passing NULL as a value to set

Passing NULL is non-sensical. The error message leaves to be desired,
though, as it leaks internal implementation details. Catch it at the
`git_config_set_string` level and set an appropriate error message.
Improved tree iterator internals

This updates the tree iterator internals to be more efficient.

The tree_iterator_entry objects are now kept as pointers that are
allocated from a git_pool, so that we may use git__tsort_r for
sorting (which is better than qsort, given that the tree is
likely mostly ordered already).

Those tree_iterator_entry objects now keep direct pointers to the
data they refer to instead of keeping indirect index values.  This
simplifies a lot of the data structure traversal code.

This also adds bsearch to find the start item position for range-
limited tree iterators, and is more explicit about using
git_path_cmp instead of reimplementing it.  The git_path_cmp
changed a bit to make it easier for tree_iterators to use it (but
it was barely being used previously, so not a big deal).

This adds a git_pool_free_array function that efficiently frees a
list of pool allocated pointers (which the tree_iterator keeps).
Also, added new tests for the git_pool free list functionality
that was not previously being tested (or used).
Fix valgrind issues (and mmap fallback for diff)

This fixes a number of issues identified by valgrind - mostly
missed free calls.  Inside valgrind, mmap() may fail which causes
some of the diff tests to fail.  This adds a fallback code path
to diff_output.c:get_workdir_content() where is the mmap() fails
the code will now try to read the file data directly into allocated
memory (which is what it would do if the data needed to be filtered
anyhow).
Added pool freelist struct for readability

This adds a git_pool_freelist_item struct that makes it a little
easier to follow what's going on with the pool free list block
management code.  It is functionally neutral.
Fix various build warnings

This fixes various build warnings on Mac and Windows (64-bit).
Merge pull request #1414 from arrbee/more-build-warning-fixes

Fix various build warnings
Merge pull request #1413 from arrbee/more-iterator-refactor

Further tree_iterator refactoring
pool: Internal struct name
odb_pack: Unused functions
Implement global/system file search paths

The goal of this work is to expose the search logic for "global",
"system", and "xdg" files through the git_libgit2_opts() interface.

Behind the scenes, I changed the logic for finding files to have a
notion of a git_strarray that represents a search path and to store
a separate search path for each of the three tiers of config file.
For each tier, I implemented a function to initialize it to default
values (generally based on environment variables), and then general
interfaces to get it, set it, reset it, and prepend new directories
to it.

Next, I exposed these interfaces through the git_libgit2_opts
interface, reusing the GIT_CONFIG_LEVEL_SYSTEM, etc., constants
for the user to control which search path they were modifying.
There are alternative designs for the opts interface / argument
ordering, so I'm putting this phase out for discussion.

Additionally, I ended up doing a little bit of clean up regarding
attr.h and attr_file.h, adding a new attrcache.h so the other two
files wouldn't have to be included in so many places.
Adds an option to select the CRT link mode ( static or dynamic ).
This is useful when linking libgit2 statically, as the setting must match the linking program's one.
Fix for a cmake bug when using MSVC + Win64 + static libraries
(see http://public.kitware.com/Bug/view.php?id=11240)
Several warnings detected by static code analyzer fixed

Implicit type conversion argument of function to size_t type
Suspicious sequence of types castings: size_t -> int -> size_t
Consider reviewing the expression of the 'A = B == C' kind. The expression is calculated as following: 'A = (B == C)'
Unsigned type is never < 0
Merge pull request #1418 from QbProg/qb/cmake-msvc

MSVC cmake improvements
Merge pull request #1080 from carlosmn/config-set-null

Failing config related test
Merge pull request #1420 from KindDragon/static-code-analyzer-warnings

Several warnings detected by static code analyzer fixed
Switch search paths to classic delimited strings

This switches the APIs for setting and getting the global/system
search paths from using git_strarray to using a simple string with
GIT_PATH_LIST_SEPARATOR delimited paths, just as the environment
PATH variable would contain.  This makes it simpler to get and set
the value.

I also added code to expand "$PATH" when setting a new value to
embed the old value of the path.  This means that I no longer
require separate actions to PREPEND to the value.
Fixes and cleanups

Get rid of some dead code, tighten things up a bit, and fix a bug
with core::env test.
Merge pull request #1417 from arrbee/opts-for-paths

Implement opts interface for global/system file search paths