def match_gitignore(path):
    elem = path[-1][0]  # path = [(name, parsed_ignore_file, mode_or_ignore)]
    is_directory = stat.S_ISDIR(path[-1][2])
    if is_directory and elem == '.git':
        return TRUNCATE

    if len(path) > 1:
        ignored = path[-2][2]
    else:
        ignored = False

    for i in range(len(path)):
        parsed_ignore_file = path[i][1]
        if not parsed_ignore_file:
            continue
        for pattern,flags in parsed_ignore_file:
            sense = not bool(flags & MATCH_INVERSE)

            # A pattern without a '/' matches everywhere
            if len(pattern) == 1:
                if pattern[0].match(elem):
                    if not flags & MATCH_END_WITH_DIRECTORY or is_directory:
                        ignored = sense

            # A pattern with a '/' matches from the start
            elif len(pattern) == len(path)-i:
                for j in range(len(pattern)):
                    if not pattern[j].match(path[i+j][0]):
                        break
                else:
                    if not flags & MATCH_END_WITH_DIRECTORY or is_directory:
                        ignored = sense
    return INCLUDE if not ignored else EXCLUDE
Translates the internal state of this object to a ``dict``.
dataset/ETHPy150Open ravello/testmill/lib/testmill/versioncontrol.py/match_gitignore--crossover with--dataset/ETHPy150Open openstack/taskflow/taskflow/persistence/models.py/FlowDetail.to_dict