def METHOD_NAME(self, line):
    # type: (str) -> Branch
    (head, ref, upstream, upstream_remote, upstream_status,
     committerdate, commit_hash, commit_msg) = line.split("\x00")
    active = head == "*"
    is_remote = ref.startswith("refs/remotes/")
    ref_ = ref.split("/")[2:]
    canonical_name = "/".join(ref_)
    if is_remote:
        remote, branch_name = ref_[0], "/".join(ref_[1:])
    else:
        remote, branch_name = None, canonical_name
    if upstream:
        is_remote_upstream = upstream.startswith("refs/remotes/")
        upstream_ = upstream.split("/")[2:]
        upstream_canonical = "/".join(upstream_)
        if is_remote_upstream:
            upstream_branch = "/".join(upstream_[len(upstream_remote.split("/")):])
        else:
            upstream_branch = upstream_canonical
        ups = Upstream(upstream_remote, upstream_branch, upstream_canonical, upstream_status)
    else:
        ups = None
    return Branch(
        branch_name,
        remote,
        canonical_name,
        commit_hash,
        commit_msg,
        active,
        is_remote,
        int(committerdate),
        upstream=ups
    )