def _parse_header(commit_name, header):
    tree = None
    parents = []
    author = None
    committer = None

    # We accept the headers in any order.
    # git itself requires them to be tree, parents, author, committer
    for line in header.split('\n'):
        try:
            (name, value) = line.split(' ', 1)
        except __HOLE__:
            msg = 'bad commit header line %r' % (line)
            raise BadCommitError(commit_name, msg)

        if name == 'tree':
            if tree:
                msg = 'multiple trees specified'
                raise BadCommitError(commit_name, msg)
            tree = value
        elif name == 'parent':
            parents.append(value)
        elif name == 'author':
            if author:
                msg = 'multiple authors specified'
                raise BadCommitError(commit_name, msg)
            author = _parse_author(commit_name, value, name)
        elif name == 'committer':
            if committer:
                msg = 'multiple committers specified'
                raise BadCommitError(commit_name, msg)
            committer = _parse_author(commit_name, value, name)
        else:
            msg = 'unknown header field %r' % (name,)
            raise BadCommitError(commit_name, msg)

    if not tree:
        msg = 'no tree specified'
        raise BadCommitError(commit_name, msg)
    if not author:
        msg = 'no author specified'
        raise BadCommitError(commit_name, msg)
    if not committer:
        msg = 'no committer specified'
        raise BadCommitError(commit_name, msg)

    return (tree, parents, author, committer)
dataset/ETHPy150Open facebookarchive/git-review/src/gitreview/git/commit.py/_parse_header