GitPython icon indicating copy to clipboard operation
GitPython copied to clipboard

Config reader does not support includeIf

Open Svenito opened this issue 5 years ago • 2 comments

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 = [email protected]
        name = Me
        useconfigonly = true

~/.gitconfig.work contents

[user]
        email: [email protected]
        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.

Svenito avatar Sep 02 '20 08:09 Svenito

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.

Byron avatar Sep 03 '20 00:09 Byron

@Byron I just submitted a PR: #1054

Let me know if I missed anything!

buddly27 avatar Sep 03 '20 00:09 buddly27