pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/libgit2/libgit2/pull/7204

sets/global-0bd78641c0a1f3e0.css" /> config: honor environment variable config overrides in `open_default` by amaanq · Pull Request #7204 · libgit2/libgit2 · GitHub
Skip to content

config: honor environment variable config overrides in open_default#7204

Open
amaanq wants to merge 1 commit intolibgit2:mainfrom
amaanq:config-open-default-env-vars
Open

config: honor environment variable config overrides in open_default#7204
amaanq wants to merge 1 commit intolibgit2:mainfrom
amaanq:config-open-default-env-vars

Conversation

@amaanq
Copy link
Copy Markdown

@amaanq amaanq commented Jan 26, 2026

Background

The following environment variables have been supported by git since version 2.32:

  • GIT_CONFIG_GLOBAL - which overrides the global config file location
  • GIT_CONFIG_SYSTEM - which overrides the system config file location
  • GIT_CONFIG_NOSYSTEM - which skips the system config entirely

#6544 added support for these environment variables when loading the config through a repository, but git_config_open_default() was not updated to use these. This function is used by tools that need to read the git configuration without an open repository (delta is one such program that does this, via the git2-rs bindings).

Solution

In this PR, I've updated git_config_open_default() such that it now respects GIT_CONFIG_GLOBAL, GIT_CONFIG_SYSTEM, and GIT_CONFIG_NOSYSTEM, which matches the behavior already implemented for repository-based config loading. I also added a few tests to ensure it functions as expected, and all tests pass on my machine :)

Thank you!

`git_config_open_default()` now checks `GIT_CONFIG_GLOBAL`,
`GIT_CONFIG_SYSTEM`, and `GIT_CONFIG_NOSYSTEM` environment variables
before falling back to standard config file locations.

This matches the behavior already implemented for repository-based
config loading, allowing tools that use libgit2's standalone config API
(like delta, gitui, etc.) to respect the same environment variables that
git honors since version 2.32.
@amaanq
Copy link
Copy Markdown
Author

amaanq commented Mar 9, 2026

Friendly ping @ethomson if you have the time :)

@ethomson
Copy link
Copy Markdown
Member

Thanks for the ping - I want to ponder this a bit, since this is a behavioral change, I wonder if we should have a flag here to determine the behavior (or if using the environment variables is always the expected behavior). 🤔

@amaanq
Copy link
Copy Markdown
Author

amaanq commented Mar 25, 2026

Hm, git itself honors these environment variables unconditionally, I don't think you can opt-in to this. Additionally, the repo-based config loading path already does this now (since #6544). I think it makes the most sense to do this unconditionally just like git, though I am not an expert :)

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

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy