Skip to content

includeIf hasconfig breaks config file parsing. #1216

Open
@dsully

Description

@dsully

Given:

[includeIf  "hasconfig:remote.*.url:ssh://org-*@github.com/**"]
     path = ~/.config/git/.work

Dulwich fails to handle this in git config:

../build/lipy-scm/environments/development-venv/lib/python3.10/site-packages/dulwich/repo.py:1681: in _init_maybe_bare
    config = StackedConfig.default()
../build/lipy-scm/environments/development-venv/lib/python3.10/site-packages/dulwich/config.py:701: in default
    return cls(cls.default_backends())
../build/lipy-scm/environments/development-venv/lib/python3.10/site-packages/dulwich/config.py:721: in default_backends
    cf = ConfigFile.from_path(path)
../build/lipy-scm/environments/development-venv/lib/python3.10/site-packages/dulwich/config.py:596: in from_path
    ret = cls.from_file(f)
../build/lipy-scm/environments/development-venv/lib/python3.10/site-packages/dulwich/config.py:556: in from_file
    section, line = _parse_section_header_line(line)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

line = b''

    def _parse_section_header_line(line: bytes) -> Tuple[Section, bytes]:
        # Parse section header ("[bla]")
        line = _strip_comments(line).rstrip()
        in_quotes = False
        escaped = False
        for i, c in enumerate(line):
            if escaped:
                escaped = False
                continue
            if c == ord(b'"'):
                in_quotes = not in_quotes
            if c == ord(b'\\'):
                escaped = True
            if c == ord(b']') and not in_quotes:
                last = i
                break
        else:
            raise ValueError("expected trailing ]")
        pts = line[1:last].split(b" ", 1)
        line = line[last + 1:]
        section: Section
        if len(pts) == 2:
            if pts[1][:1] != b'"' or pts[1][-1:] != b'"':
>               raise ValueError("Invalid subsection %r" % pts[1])
E               ValueError: Invalid subsection b' "hasconfig:remote.*.url:ssh://org-*@github.com/**"'

../build/lipy-scm/environments/development-venv/lib/python3.10/site-packages/dulwich/config.py:513: ValueError

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions