|
@@ -512,6 +512,47 @@ class BuildIndexTests(TestCase):
|
|
|
self.assertEqual(index[b'c'][4], S_IFGITLINK)
|
|
|
self.assertEqual(index[b'c'][8], c.id)
|
|
|
|
|
|
+ def test_git_submodule_exists(self):
|
|
|
+ repo_dir = tempfile.mkdtemp()
|
|
|
+ self.addCleanup(shutil.rmtree, repo_dir)
|
|
|
+ with Repo.init(repo_dir) as repo:
|
|
|
+ filea = Blob.from_string(b'file alalala')
|
|
|
+
|
|
|
+ subtree = Tree()
|
|
|
+ subtree[b'a'] = (stat.S_IFREG | 0o644, filea.id)
|
|
|
+
|
|
|
+ c = Commit()
|
|
|
+ c.tree = subtree.id
|
|
|
+ c.committer = c.author = b'Somebody <somebody@example.com>'
|
|
|
+ c.commit_time = c.author_time = 42342
|
|
|
+ c.commit_timezone = c.author_timezone = 0
|
|
|
+ c.parents = []
|
|
|
+ c.message = b'Subcommit'
|
|
|
+
|
|
|
+ tree = Tree()
|
|
|
+ tree[b'c'] = (S_IFGITLINK, c.id)
|
|
|
+
|
|
|
+ os.mkdir(os.path.join(repo_dir, 'c'))
|
|
|
+ repo.object_store.add_objects(
|
|
|
+ [(o, None) for o in [tree]])
|
|
|
+
|
|
|
+ build_index_from_tree(repo.path, repo.index_path(),
|
|
|
+ repo.object_store, tree.id)
|
|
|
+
|
|
|
+
|
|
|
+ index = repo.open_index()
|
|
|
+ self.assertEqual(len(index), 1)
|
|
|
+
|
|
|
+
|
|
|
+ apath = os.path.join(repo.path, 'c/a')
|
|
|
+ self.assertFalse(os.path.exists(apath))
|
|
|
+
|
|
|
+
|
|
|
+ cpath = os.path.join(repo.path, 'c')
|
|
|
+ self.assertTrue(os.path.isdir(cpath))
|
|
|
+ self.assertEqual(index[b'c'][4], S_IFGITLINK)
|
|
|
+ self.assertEqual(index[b'c'][8], c.id)
|
|
|
+
|
|
|
|
|
|
class GetUnstagedChangesTests(TestCase):
|
|
|
|