def read_ignore_patterns(f):
    """Read a git ignore file.

    :param f: File-like object to read from
    :return: List of patterns
    """
    for line in f:
        line = line.rstrip(b'\r\n')
        if not line:
            continue
        if line.startswith(b'#'):
            continue
        while line.endswith(b' ') and not line.endswith(b'\\ '):
            line = line[:-1]
        line = line.replace(b'\\ ', b' ')
        yield line
