+ def test_git_dir(self):
+ if os.name != 'posix':
+ self.skipTest("test depends on POSIX shell")
+
+ repo_dir = tempfile.mkdtemp()
+ repo = Repo.init(repo_dir)
+ self.addCleanup(shutil.rmtree, repo_dir)
+
+ # Populate repo
+ filea = Blob.from_string('file a')
+ filee = Blob.from_string('d')
+
+ tree = Tree()
+ tree['.git/a'] = (stat.S_IFREG | 0o644, filea.id)
+ tree['c/e'] = (stat.S_IFREG | 0o644, filee.id)
+
+ repo.object_store.add_objects([(o, None)
+ for o in [filea, filee, tree]])
+
+ build_index_from_tree(repo.path, repo.index_path(),
+ repo.object_store, tree.id)
+
+ # Verify index entries
+ index = repo.open_index()
+ self.assertEqual(len(index), 1)
+
+ # filea
+ apath = os.path.join(repo.path, '.git', 'a')
+ self.assertFalse(os.path.exists(apath))
+
+ # filee
+ epath = os.path.join(repo.path, 'c', 'e')
+ self.assertTrue(os.path.exists(epath))
+ self.assertReasonableIndexEntry(index['c/e'],
+ stat.S_IFREG | 0o644, 1, filee.id)
+ self.assertFileContents(epath, 'd')
+