'Returns the remote ref for \'git diff [local] [remote]\''

def remote_ref(self, branch):

    if (branch == self.BRANCH_POINT):
        branch = gitcmds.current_branch()
        tracked_branch = gitcmds.tracked_branch()
        if tracked_branch:
            return gitcmds.merge_base(branch, tracked_branch)
        else:
            remote_branches = gitcmds.branch_list(remote=True)
            remote_branch = (u'origin/%s' % branch)
            if (remote_branch in remote_branches):
                return gitcmds.merge_base(branch, remote_branch)
            elif (u'origin/master' in remote_branches):
                return gitcmds.merge_base(branch, u'origin/master')
            else:
                return u'HEAD'
    else:
        return branch
