def test_commit_chain(self):
        def assert_head_ancestor(repo, ancestor_id):
            commit = repo.commit(repo.head())
            while True:
                try:
                    commit_id = commit.get_parents()[0]
                except __HOLE__:
                    self.fail('ancestor not in history of current head')

                if commit_id == ancestor_id:
                    return # we found the ancestor; test successful

                commit = repo.commit(commit_id)

        c = self.repo.get_root()['b']['c']
        HEAD_0 = dulwich.repo.Repo(self.repo_path).head()
        c.create_directory('x')

        repo = dulwich.repo.Repo(self.repo_path)
        HEAD_1 = repo.head()
        assert_head_ancestor(repo, HEAD_0)

        c['x'].create_file('f')
        repo = dulwich.repo.Repo(self.repo_path)
        assert_head_ancestor(repo, HEAD_1)
dataset/ETHPy150Open mgax/SpaghettiFS/spaghettifs/tests/test_storage.py/GitStructureTestCase.test_commit_chain