From 3052943e55f67046707bd7eb96a40c88a76c5919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Mon, 7 Sep 2026 17:33:49 +0200 Subject: [PATCH] test: add regression test for blob reading next to a submodule Reading a blob's content in a tree that also contains a submodule used to fail (issue #12) because the tree parser did not recognize the "commit" entry type. This has since been fixed, but there was no test covering the scenario, so add one to prevent a regression. --- tests/Gitonomy/Git/Tests/BlobTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/Gitonomy/Git/Tests/BlobTest.php b/tests/Gitonomy/Git/Tests/BlobTest.php index 9c6fa44..5673e78 100644 --- a/tests/Gitonomy/Git/Tests/BlobTest.php +++ b/tests/Gitonomy/Git/Tests/BlobTest.php @@ -39,6 +39,21 @@ public function testGetContent(Repository $repository): void $this->assertStringContainsString(self::README_FRAGMENT, $blob->getContent()); } + #[DataProvider('provideFoobar')] + public function testGetContentSiblingToSubmodule(Repository $repository): void + { + // Regression test for https://github.com/gitonomy/gitlib/issues/12: + // a submodule entry in a tree used to break parsing of that tree, + // making sibling blobs unreadable. + $tree = $repository->getCommit(self::NO_MESSAGE_COMMIT)->getTree(); + + $this->assertNotEmpty($tree->getCommitReferenceEntries(), 'Tree contains a submodule entry'); + + $blob = $tree->resolvePath('README.md'); + + $this->assertStringContainsString(self::README_FRAGMENT, $blob->getContent()); + } + #[DataProvider('provideFoobar')] public function testNotExisting(Repository $repository): void {