libgit2 / libgit2

A cross-platform, linkable library implementation of Git that you can use in your application.

Home Page:https://libgit2.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

write config properties at specific level

albfan opened this issue · comments

config is able to merge all levels of config and show definitive results

but is not able to write on specific level.

Seems it search for a parameter name and if not found go up in level and write to the most high one.

Do we miss a git_config_set_entry where we specifically set the ConfigEntry to the LEVEL we need?

Use cases:

user.name and user.email:

- Set at local level : it overrides that
- Set at global level: it overrides that
- Set at local level but you want to set at global: Not possible
- Set at global level but you want to set at local: Not possible
- Not set at all: You might want to set for global or local, but it will only set as global

I think is ok to set at higher level or override existing property, but doesn't look complext to add set_entry and allow user to decide in specific scenarios

This makes sense, and should be feasible, though I'm not sure how difficult this would be to implement offhand.

I can give a try, let me check

I think that the right thing here is the current situation which is to get the level explicitly, then write to it. For example:

git_config *global;
git_config_open_level(&global, cfg, GIT_CONFIG_LEVEL_GLOBAL));
git_config_set_int32(global, "core.value", 42);

I'd be happy to consider a PR if you want to improve the DX here, but I'm going to close the issue for now.

Thanks, @ethomson. I Guess I can do tries around that and see if we can wrap around It (check if a property exist at some level, etc...) we just need to control if a property exist at local level,

Let me know if I didn't understand your use case fully, and we really do need some new APIs here!

@ethomson thanks a lot, it's already cover in our vala wrapper: https://valadoc.org/libgit2-glib-1.0/Ggit.Config.open_level.html