def ref_type(ref):
    """Return branch, tag, sha, or unknown ref type

    :param str ref: Full pathspec
    :return: 'branch', 'tag', 'sha', or 'unknown'
    :rtype: str
    """
    git_branch = 'refs/heads/'
    git_tag = 'refs/tags/'
    if ref.startswith(git_branch):
        return 'branch'
    elif ref.startswith(git_tag):
        return 'tag'
    elif len(ref) == 40:
        return 'sha'
    return 'unknown'
