def is_git_dir(d):
    isdir = os.path.isdir
    join = os.path.join
    isfile = os.path.isfile
    islink = os.path.islink
    if isdir(d) and isdir(join(d, 'objects')) and isdir(join(d, 'refs')):
        headref = join(d, 'HEAD')
        return isfile(headref) or (islink(headref) and
                                   os.readlink(headref).startswith('refs'))
    return False
called in main extension script to actually get a usable session
dataset/ETHPy150Open douban/ellen/ellen/repo.py/is_git_dir--crossover with--dataset/ETHPy150Open pilotmoon/PopClip-Extensions/source/Trello/auth.py/get_session