commit ca2e25ad393bb25c9a4d81918e8612fd6354de51 from: Will Shanks date: Mon Apr 22 22:02:02 2024 UTC Handle alternate case for worktreeconfig setting `extensions.worktreeconfig` was checked in a way that was not case-insensitive, but git config settings should be case insensitive. This behavior led to problems since the documentation describes the setting as `worktreeConfig` and GitHub Actions started setting the option with this casing. Fixes https://github.com/jelmer/dulwich/issues/1285 commit - 3556e52bb65c98e478ed3ff184bbcddedbbe2231 commit + ca2e25ad393bb25c9a4d81918e8612fd6354de51 blob - d87c93382b8d392870534e8be78d2f3dcc2eecbe blob + b564a0e4c5f28780c71a4c5bca42fcaa0d3ec946 --- dulwich/repo.py +++ dulwich/repo.py @@ -1191,7 +1191,7 @@ class Repo(BaseRepo): raise UnsupportedVersion(format_version) for extension, _value in config.items((b"extensions",)): - if extension not in (b"worktreeconfig",): + if extension.lower() not in (b"worktreeconfig",): raise UnsupportedExtension(extension) if object_store is None: blob - a063c45760ce8294805392e458913e61f34800cf blob + d0b7c7705fd839e340f5d0c86ab5f0304db9304c --- tests/test_repository.py +++ tests/test_repository.py @@ -1141,6 +1141,22 @@ class BuildRepoRootTests(TestCase): c.write_to_path() cs = r.get_config_stack() self.assertEqual(cs.get(("user",), "name"), b"Jelmer") + + def test_worktreeconfig_extension_case(self): + """Test that worktree code does not error for alternate case format""" + r = self._repo + c = r.get_config() + c.set(("core",), "repositoryformatversion", "1") + # Capitalize "Config" + c.set(("extensions",), "worktreeConfig", True) + c.write_to_path() + c = r.get_worktree_config() + c.set(("user",), "repositoryformatversion", "1") + c.set((b"user",), b"name", b"Jelmer") + c.write_to_path() + # The following line errored before + # https://github.com/jelmer/dulwich/issues/1285 was addressed + Repo(self._repo_dir) def test_repositoryformatversion_1_extension(self): r = self._repo