Skip to content

Commit

Permalink
Handle alternate case for worktreeconfig setting (#1286)
Browse files Browse the repository at this point in the history
`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 #1285
  • Loading branch information
jelmer committed Apr 23, 2024
2 parents 3556e52 + 4ce425c commit 53d3dfe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dulwich/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ def __init__(
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:
Expand Down
16 changes: 16 additions & 0 deletions tests/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,22 @@ def test_worktreeconfig_extension(self):
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
c = r.get_config()
Expand Down

0 comments on commit 53d3dfe

Please sign in to comment.