WIP: refs.c: Add rules for resolving refs using remote refspecs

WIP: This strcmp is needed when we add the extra rule for remote refspec resolving
FIXME: Add shortening of remote-tracking branches into shorthand names as well (separate patch?).
FIXME: Add _lots_ of tests
FIXME: Add removal of { ref_expand_txtly, ref_shorten_txtly, "refs/remotes/%.*s" } as the next commit (does it pass tests?).
FIXME: What about { ref_expand_txtly, ref_shorten_txtly, "refs/remotes/%.*s/HEAD" }, txtly -> refspec entry?
FIXME: What about prettify_refname()?

The "$remote/$branch" expression is often used as a shorthand with the
intention of referring to the remote-tracking branch corresponding to
the given $branch in the $remote repo.

Currently, Git resolves this by prepending "refs/remotes/" to the given
"$remote/$branch" expression, resulting in "refs/remotes/$remote/$branch",
which is equivalent to the above intention only when conventional
refspecs are being used (e.g. refs/heads/*:refs/remotes/origin/*).

If unconventional refspecs (e.g. refs/heads/*:refs/remotes/origin/heads/*)
are being used, then the current expansion ("refs/remotes/$remote/$branch")
fails to match the remote-tracking branches from the configured remotes.

Instead of doing a pure textual expansion (from "$remote/$branch" to
"refs/remotes/$remote/$branch"), we should find all remotes matching
"$remote", look up their fetch refspecs, and map "refs/heads/$branch"
through them to find the appropriate remote-tracking branch name
corresponding to "$remote/$branch". This would yield the correct
remote-tracking branch in all cases, both for conventional and
unconventional refspecs.

This patch adds a new expansion method - ref_expand_refspec() - that
performs the remote refspec traversal described above. This expansion
method complements the existing ref_expand_txtly() which performs the
current textual expansion.

Implementing the proper expansion of "$remote/$branch" is now a simple
matter of adding another entry to the ref_expand_rules list, using the
ref_expand_refspec() expansion function.

Note that the  existing "refs/remotes/*" textual expansion is kept to
preserve backwards compatibility for refs under refs/remotes/* that are
not covered by any configured refspec.

Signed-off-by: Johan Herland <johan@herland.net>