refs: conditional ref updates

Allow updating references if the old value matches the given one.
refs: changes from feedback

Change the name to _matching() intead of _if(), and force _set_target()
to be a conditional update. If the user doesn't care about the old
value, they should use git_reference_create().
refs: return GIT_EMODIFIED if the ref target moved

In case we loose the race to update the reference, return GIT_EMODIFIED
to let the user distinguish it from other types of errors.
refs: fix leak on successful update

Free the old ref even on success.
refs: add tests for conditional updates
refdb: add conditional symbolic updates

Add a parameter to the backend to allow checking for the old symbolic
target.
refs: bring conditional symbolic updates to the frontend

Bring the race detection goodness to symbolic references as well.
refs: factor out old value comparison

We will reuse this later for deletion.
refs: placeholder conditional delete

We don't actually pass the old value yet.
refs: check the ref's old value when deleting

Recognize when the reference has changed since we loaded it.
refs: catch cases where the ref type has changed

If the type of the on-disk reference has changed, the old value
comparison should fail.
refs: add an unconditional delete

Add it under the git_reference_remove() name, letting the user pass the
repo and name, analogous to unconditional setting/creation.
Merge pull request #2042 from libgit2/cmn/conditional-ref

refs: conditional ref updates