Implement ConfigLoader plugins that aligns with upstream behaviour#1924
Draft
pjbgf wants to merge 3 commits intogo-git:mainfrom
Draft
Implement ConfigLoader plugins that aligns with upstream behaviour#1924pjbgf wants to merge 3 commits intogo-git:mainfrom
ConfigLoader plugins that aligns with upstream behaviour#1924pjbgf wants to merge 3 commits intogo-git:mainfrom
Conversation
Signed-off-by: Paulo Gomes <paulo@entire.io>
…tations Disk reads configuration solely from standard Git file locations on the host filesystem without consulting environment variables. It supports both Unix (/etc/gitconfig, ~/.gitconfig, ~/.config/git/config) and Windows (%PROGRAMFILES%\Git\etc\gitconfig, %USERPROFILE%\.gitconfig). Environment honours GIT_CONFIG_GLOBAL, GIT_CONFIG_SYSTEM, GIT_CONFIG_NOSYSTEM, XDG_CONFIG_HOME, and %APPDATA% (Windows) for locating configuration files. Auto mimics default Git behaviour by merging all candidate config files in precedence order, with environment variable overrides replacing the default disk paths when set. Signed-off-by: Paulo Gomes <paulo@entire.io> Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Paulo Gomes <paulo@entire.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
config.LoadConfigand theconfig.Pathshelper in favour of theConfigLoaderplugin, centralising all scoped config resolution throughConfigSource.ConfigSourceimplementations:Disk(host filesystem only),Environment(respectsGIT_CONFIG_*andXDG_CONFIG_HOME), andAuto(merges both, matching default Git behaviour).ConfigLoaderplugin documentation.Opt-in to Git's behaviour when using
go-gitParts of
go-gitthat depend on system or global configuration began using theConfigLoaderplugin with the introduction of #1860. By default,config.Configsfor bothSystemandGlobalare initialized as empty. This behaviour is intentional, as it prevents unintended side effects in applications that usego-gitto automate operations outside of a user-specific context.For applications that need
go-gitto mimic the behavior of the standard git CLI, this can be enabled by registering theAutoConfigSource:Fixes #395 #1701 #1849.
Supersedes #1702.
Follows-up from #1860.