ITADN

Does git2-rs respect the `GIT_CONFIG_GLOBAL` environment variable?

#1192ClosedDaniel-De-Dev 创建于 2025-11-15
D
Daniel-De-Devcommented
I have the [`GIT_CONFIG_GLOBAL`](https://git-scm.com/docs/git#Documentation/git.txt-GITCONFIGGLOBAL) variable set to a gitconfig file i've created, and it works fine. Git detects them and applies them as expected without problem. But on [delta](https://github.com/dandavison/delta) which has the following function defined [`try_create()` ](https://github.com/dandavison/delta/blob/ae1d2d5a41f9c6b4c65344e33e95d3e3cf7a42f3/src/git_config/mod.rs#L40-L68) When i have `GIT_CONFIG_GLOBAL` defined to a real file, its not able to detect the `[delta]` options define in the file. But when i move the options to a well known location like `~/.gitconfig` it works and delta is able to find the options. So that's why i'm wondering if it's git2's [`pub fn open_default() -> Result<Config, Error>`](https://docs.rs/git2/latest/git2/struct.Config.html#method.open_default) & [`pub fn config -> Result<Config, Error>`](https://docs.rs/git2/latest/git2/struct.Repository.html#method.config) which doesn't take into account if the environment variables are set. I must admit im not familiar with how git2-rs works and how it handles generating the complete config. But from my limited testing it seems that it checks expected locations, merges the them based on some priority structure and returns it as some `Config` object Is it the case that it doesn't check for location defined trough environment variables (`GIT_CONFIG_GLOBAL` & `GIT_CONFIG_SYSTEM`)? _(i now realize this question might be more appropriate on the actual libgit2 repo)_
关闭于 2025-11-15 1 条评论