def cleanup_mode(mode):
    if stat.S_ISLNK(mode):
        return stat.S_IFLNK
    elif stat.S_ISDIR(mode):
        return stat.S_IFDIR
    elif S_ISGITLINK(mode):
        return S_IFGITLINK
    ret = stat.S_IFREG | 0644
    ret |= (mode & 0111)
    return ret
Tests:
dataset/ETHPy150Open natestedman/Observatory/observatory/lib/dulwich/index.py/cleanup_mode--crossover with--dataset/ETHPy150Open typesupply/woffTools/Lib/woffTools/tools/validate.py/_testHeaderReserved