def search(defname,head_commit="HEAD"):
    HEAD,s = get_commit_vitals("HEAD")[:2]
    logger.info("HEAD at %s: %s" % (HEAD,s))
    done_commits = set()
    # allhits = set()
    files = []
    state = dict(files=files)
    os.path.walk('.',file_filter,state)
    # files now holds a list of paths to files

    # seed with hits from q
    allhits= set(get_hits(defname, files = files))
    q = set([HEAD])
    try:
        while q:
            h=q.pop()
            clean_checkout(h)
            hits = get_hits(defname, files = files)
            for x in hits:
                prevc = get_commit_vitals(x.commit+"^")[0]
                if prevc not in done_commits:
                    q.add(prevc)
            allhits.update(hits)
            done_commits.add(h)

            logger.debug("Remaining: %s" % q)
    finally:
        logger.info("Restoring HEAD to %s" % HEAD)
        clean_checkout(HEAD)
    return allhits
dataset/ETHPy150Open pydata/pandas/scripts/find_commits_touching_func.py/search/original