Skip to content

GitConfigParser().get_values() does not load sections properly. #1534

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

Closed
kf-novi opened this issue Jan 10, 2023 · 3 comments
Closed

GitConfigParser().get_values() does not load sections properly. #1534

kf-novi opened this issue Jan 10, 2023 · 3 comments

Comments

@kf-novi
Copy link

kf-novi commented Jan 10, 2023

To replicate this bug, first do the following in your CLI

git config --global --add safe.directory /some/directory/here

Then run this python script

from git import GitConfigParser
from git.config import get_config_path

config = GitConfigParser(get_config_path("global"), read_only=False)
config.get_values("safe", "directory") # This throws a KeyError

There is a workaround:

config.get_value("safe", "directory")
config.get_values("safe", "directory") # This works

I will be taking a look at the code to see if I can submit a PR for this.

@Byron
Copy link
Member

Byron commented Feb 16, 2023

Closing as it's fixed by #1555 .

@Byron Byron closed this as completed Feb 16, 2023
@larstobi
Copy link

I'm still getting the KeyError: 'safe' in version 3.1.43 (using Python 3.12.4), but only if the safe section is not already present in the git config. The above workaround with calling .get_value() first still works, though.
@Byron
#1555

@Byron
Copy link
Member

Byron commented Sep 16, 2024

Maybe you can contribute a test that reproduces the issue. From there it should be possible to fix the issue for good. Thanks a lot.

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

No branches or pull requests

3 participants