def git_packet(data=None):
    """Format data as a git pktline

    If data is None, a flush packet will be returned"""
    if data is None:
        return '0000'
    return str(hex(len(data) + 4)[2:].rjust(4, '0')) + data
