localrepo: Fix lookup of wrong ref if requesting prefix
When passing a prefix to git-for-each-ref(1), it'll simply print all
branches whose reference name starts with that prefix. We fail to
account for that in localrepo.GetReference()
, which as a result may
lead us to simply returning the first branch we've found in case a
prefix is handed to us.
Fix this issue by comparing the returned branch name with what was searched for. If it doesn't match, then we return an error saying the reference is ambiguous. Ideally, we'd just tell git to ignore non-exact matches, but seemingly that isn't possible.