Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

includeIf hasconfig breaks config file parsing. #1216

Open
dsully opened this issue Sep 22, 2023 · 0 comments
Open

includeIf hasconfig breaks config file parsing. #1216

dsully opened this issue Sep 22, 2023 · 0 comments

Comments

@dsully
Copy link

dsully commented Sep 22, 2023

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants