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

Add local .git/config support #883

Closed
wants to merge 1 commit into from
Closed

Add local .git/config support #883

wants to merge 1 commit into from

Conversation

0x2b3bfa0
Copy link

@0x2b3bfa0 0x2b3bfa0 commented Jun 12, 2021

This pull request allows Dulwich to load local configuration from .git/config through StackedConfig.default() by inferring the configuration file path from either the GIT_DIR environment variable or the current directory. The added functions are simplified implemetations of the following Git functions:

I don't know if taking into account the current working directory is too unpredictable for non-porcelain code, though. Any feedback would be highly appreciated.

Previously, local configuration was ignored in all but a few select 
cases
@jelmer
Copy link
Owner

jelmer commented Jun 12, 2021

Thanks for the pull request.

The three helper functions belong in dulwich.repo, since they're not config-specific. The functionality already exists today, so if you factor out into separate functions please update the existing code to use those functions as well.

Config.default_backends() intentionally doesn't use try to load the local repository configuration. See Repo.get_config_stack() for that.

@0x2b3bfa0
Copy link
Author

0x2b3bfa0 commented Jun 12, 2021

🙏🏼 Thank you very much for your reply!

The three helper functions belong in dulwich.repo, since they're not config-specific. The functionality already exists today, so if you factor out into separate functions please update the existing code to use those functions as well.

I've noticed that read_gitfile already exists on dulwich/repo.py and both Repo.__init__ and Repo.discover already implement the proposed functionality. 🙈

Config.default_backends() intentionally doesn't use try to load the local repository configuration. See Repo.get_config_stack() for that.

As per #638 (comment), dulwich.porcelain.<command> should work like git <command> [...] including behaviour around os.getcwd 🤔 If Config.default_backends() is not intended to replicate the functionality of git-config as suggested in the code, where should this logic be implemented?

@jelmer
Copy link
Owner

jelmer commented Jun 12, 2021 via email

@0x2b3bfa0
Copy link
Author

0x2b3bfa0 commented Jun 12, 2021

Understood! This pull request doesn't make any sense at all: Repo.discover().get_config_stack() does exactly the same thing I tried to do, and it would just be matter of connecting it to the porcelain functions that need it. 🤦🏼 Sorry for the noise.

@0x2b3bfa0 0x2b3bfa0 closed this Jun 12, 2021
@0x2b3bfa0 0x2b3bfa0 deleted the local-git-config-support branch June 12, 2021 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants