-
Notifications
You must be signed in to change notification settings - Fork 803
plumbing: format, config.Merged to allow access to local and global config #20
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
Conversation
...for reading and writing global (~/.git/config) and reading system (/etc/gitconfig) configs in addition to local repo config
Can you fix the "Test" suite? Something is missing on the PR |
Thank you for picking this up @cap10morgan |
Thank you for the shoulders to stand on! |
Yep, sorry about that. |
Ok, the code for the merge thing looks complex but fair. My only concern is about the example and promulgating the usage of the Also, if we are planning to use the author and committer info from the config, we should add the fields to it, as we have |
|
||
type Scope int | 8000||
|
||
const ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation, in general, will be good, at least in the structs and consts.
Done in 4d4e2b1.
OK. I'm working on some code to do that, but will post a separate PR for it. |
Thanks for the PR ! Any idea of when the next release with this feature will be published ? |
plumbing: format, config.Merged to allow access to local and global config
...for reading and writing global (
~/.gitconfig
) and reading system (/etc/gitconfig
) configs in addition to local repo config.This is heavily based on / inspired by @djgilcrease's PR on the original src-d repo: src-d/go-git#1243. However, I ran into an issue using that code where if you ran
SetConfig
it would write out the merged system, global, and local config params all to your local./.git/config
file, which was hard to fix under that architecture.So, I tried to take a simpler starting approach with this PR but still allow it to accomplish my 2 goals:
/etc/gitconfig
), global (~/.gitconfig
), and local (./.git/config
) configs with the same precedence ordering that git itself uses (local overrides global overrides system).The way I did this was basically to leave the higher-level config stuff (e.g.
.Remotes
,.Core.IsBare
) alone and add a new.Merged
param that works similarly to.Raw
but brings in these other configs. So now you can see the merged view with things like.Merged.Section("foo").Option("bar")
(which is all read-only) or set options with things like.Merged.GlobalConfig().AddOption(...)
..Raw
now delegates to.Merged.LocalConfig()
.I added a config example to demonstrate some of the usage and a couple of tests of marshalling and unmarshalling the different configs.