Skip to content

Config reader does not support includeIf #1053

Open
@Svenito

Description

@Svenito

If the .gitconfig file includes an includeIf directive, the config parser doesn't respect it.

~/.gitconfig file contents:

[includeIf "gitdir:~/work/git/"]
        path = ~/.gitconfig.work

[user]
        email = my@email.com
        name = Me
        useconfigonly = true

~/.gitconfig.work contents

[user]
        email: work@email.com
        name = Work

Change to the ~/work/git/project directory and run git config -l and notice that the name is set to Work. Running the following in a Python REPL

import os
from git import Repo
repo = Repo(os.getcwd())
repo.repo.config_reader().get_value("user", "name")
'Me'

And if the user hasn't got a default user setting in the ~/gitconfig file, it will throw ConfigParser.NoSectionError: No section: 'user' which is expected.

Config parser should support the includeIf directive in the config file.

Activity

Byron

Byron commented on Sep 3, 2020

@Byron
Member

Thanks for the summary!

As the implementation does support include directives already, at least in theory that should provide the necessary infrastructure to add support for conditional includes.

Here is the a link to the git documentation in case anyone wants to give it a try.

buddly27

buddly27 commented on Sep 3, 2020

@buddly27
Contributor

@Byron I just submitted a PR: #1054

Let me know if I missed anything!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Svenito@Byron@buddly27

        Issue actions

          Config reader does not support includeIf · Issue #1053 · gitpython-developers/GitPython