refs: Centralize reference creation logic
refs: Introduce git_reference_create_with_log()
refs: Introduce git_reference_symbolic_create_with_log()
refs: Introduce git_reference_set_target_with_log()
refs: Introduce git_reference_symbolic_set_target_with_log()
refs: adjust to the new reflog API
refdb: add a `message` parameter for appending to the log

This is as yet unused.
reflog: integrate into the ref writing

Whenever a reference is created or updated, we need to write to the
reflog regardless of whether the user gave us a message, so we shouldn't
leave that to the ref frontend, but integrate it into the backend.

This also eliminates the race between ref update and writing to the
reflog, as we protect the reflog with the ref lock.

As an additional benefit, this reflog append on the backend happens by
appending to the file instead of parsing and rewriting it.
reflog: remove git_reflog_append_to()

This was a convenience method for the refs front-end to do the reflog
writing. This is now done in the backend and it has no more reason for
being.
reflog: write to the reflog following git's rules

git-core only writes to the reflogs of HEAD, refs/heads/ and,
refs/notes/ or if there is already a reflog in place. Adjust our code to
follow these semantics.
refs: expose a way to ensure a ref has a log

Sometimes (e.g. stash) we want to make sure that a log will be written,
even if it's not in one of the standard locations. Let's make that
easier.
refs: expose has_log() on the backend

The frontend used to look at the file directly, but that's obviously not
the right thing to do. Expose it on the backend and use that function
instead.
Add config read fns with controlled error behavior

This adds `git_config__lookup_entry` which will look up a key in
a config and return either the entry or NULL if the key was not
present.  Optionally, it can either suppress all errors or can
return them (although not finding the key is not an error for this
function).  Unlike other accessors, this does not normalize the
config key string, so it must only be used when the key is known
to be in normalized form (i.e. all lower-case before the first dot
and after the last dot, with no invalid characters).

This also adds three high-level helper functions to look up config
values with no errors and a fallback value.  The three functions
are for string, bool, and int values, and will resort to the
fallback value for any error that arises.  They are:

* `git_config__get_string_force`
* `git_config__get_bool_force`
* `git_config__get_int_force`

None of them normalize the config `key` either, so they can only
be used for internal cases where the key is known to be in normal
format.
Improve GIT_EUSER handling

This adds giterr_user_cancel to return GIT_EUSER and clear any
error message that is sitting around.  As a result of using that
in places, we need to be more thorough with capturing errors that
happen inside a callback when used internally.  To help with that,
this also adds giterr_capture and giterr_restore so that when we
internally use a foreach-type function that clears errors and
converts them to GIT_EUSER, it is easier to restore not just the
return value, but the actual error message text.
Further EUSER and error propagation fixes

This continues auditing all the places where GIT_EUSER is being
returned and making sure to clear any existing error using the
new giterr_user_cancel helper.  As a result, places that relied
on intercepting GIT_EUSER but having the old error preserved also
needed to be cleaned up to correctly stash and then retrieve the
actual error.

Additionally, as I encountered places where error codes were not
being propagated correctly, I tried to fix them up.  A number of
those fixes are included in the this commit as well.
Add git_vector_free_all

There are a lot of places that we call git__free on each item in
a vector and then call git_vector_free on the vector itself.  This
just wraps that up into one convenient helper function.
Remove converting user error to GIT_EUSER

This changes the behavior of callbacks so that the callback error
code is not converted into GIT_EUSER and instead we propagate the
return value through to the caller.  Instead of using the
giterr_capture and giterr_restore functions, we now rely on all
functions to pass back the return value from a callback.

To avoid having a return value with no error message, the user
can call the public giterr_set_str or some such function to set
an error message.  There is a new helper 'giterr_set_callback'
that functions can invoke after making a callback which ensures
that some error message was set in case the callback did not set
one.

In places where the sign of the callback return value is
meaningful (e.g. positive to skip, negative to abort), only the
negative values are returned back to the caller, obviously, since
the other values allow for continuing the loop.

The hardest parts of this were in the checkout code where positive
return values were overloaded as meaningful values for checkout.
I fixed this by adding an output parameter to many of the internal
checkout functions and removing the overload.  This added some
code, but it is probably a better implementation.

There is some funkiness in the network code where user provided
callbacks could be returning a positive or a negative value and
we want to rely on that to cancel the loop.  There are still a
couple places where an user error might get turned into GIT_EUSER
there, I think, though none exercised by the tests.
Fix C99 __func__ for MSVC
Some callback error check style cleanups

I find this easier to read...
Further callback error check style fixes

Okay, I've decided I like the readability of this style much
better so I used it everywhere.