branch: add getter for the upstream remote name

This gets the value from branch.<foo>.remote.
remote: use git_branch_upstream_remote()

This reduces the clutter somewhat and lets us see what we're asking
about the reference.
remote: don't check for upstream on an anonymous remote

If the remote is anonymous, then we cannot check for any configuration,
as there is no name. Check for this before we try to use the name, which
may be a NULL pointer.

This fixes #2697.
remote: refactor the reference-update decision

This is an ugly chunk of code, so let's put it into its own function.
Merge pull request #2698 from libgit2/cmn/fetchhead-refactor

Refactor fetchhead