Skip to content

Commit

Permalink
Handle alternate case for worktreeconfig setting
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
wshanks committed Apr 22, 2024
1 parent 3556e52 commit ca2e25a
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 ca2e25a

Please sign in to comment.