

def is_git_dir(d):
    " This is taken from the git setup.c:is_git_directory\n    function.\n\n    @throws WorkTreeRepositoryUnsupported if it sees a worktree directory. It's quite hacky to do that here,\n            but at least clearly indicates that we don't support it.\n            There is the unlikely danger to throw if we see directories which just look like a worktree dir,\n            but are none."
    if isdir(d):
        if (isdir(join(d, 'objects')) and isdir(join(d, 'refs'))):
            headref = join(d, 'HEAD')
            return (isfile(headref) or (os.path.islink(headref) and os.readlink(headref).startswith('refs')))
        elif (isfile(join(d, 'gitdir')) and isfile(join(d, 'commondir')) and isfile(join(d, 'gitfile'))):
            raise WorkTreeRepositoryUnsupported(d)
    return False

dataset/ETHPy150Open gitpython-developers/GitPython/git/repo/fun.py is_git_dir/original