Repository navigation
Read gvfs.* booleans with git when the environment changes config - #2179
Open
Tyrie Vella (tyrielv) wants to merge 1 commit into
Open
Tyrie Vella (tyrielv) wants to merge 1 commit into
Tyrie Vella (tyrielv) wants to merge 1 commit into
Conversation
Tyrie Vella (tyrielv)
force-pushed
the
tyrielv/libgit2-config-env-fallback
branch
from
November 12, 2026 16:52
b1fce40 to
4d33e28
Compare
This was referenced Nov 12, 2026
Tyrie Vella (tyrielv)
force-pushed
the
tyrielv/libgit2-config-env-fallback
branch
2 times, most recently
from
November 12, 2026 18:00
e58e786 to
b49332f
Compare
Tyrie Vella (tyrielv)
marked this pull request as ready for review
November 12, 2026 18:24
libgit2 does not read the config that GIT_CONFIG_GLOBAL, GIT_CONFIG_SYSTEM, GIT_CONFIG_NOSYSTEM, GIT_CONFIG, GIT_CONFIG_COUNT, or GIT_CONFIG_PARAMETERS select or supply. RetryConfig already reads its settings with git.exe in that case. The boolean gvfs.* settings did not. For example, gvfs.trust-pack-indexes, gvfs.prefetch-offload, and gvfs.show-hydration-status ignored a value that came from one of these variables, and the read used the user's real config instead. When LibGit2Repo.EnvironmentChangesGitConfig() is true, read these settings with "git config --type=bool". Git normalizes the value, exits with 1 when the key is unset, and fails when the value is not a boolean. - Add the LibGit2Repo.TryReadConfigBoolWithGit delegate. The static LibGit2Repo.GetConfigBoolOrDefault and every LibGit2RepoInvoker constructor require it. Remove the invoker constructors that took no reader. - Keep the failure policy of each read path. The static helper logs the failure and returns the default. The invoker throws when git cannot read the key, as its libgit2 read does. This keeps an invalid gvfs.enable-packfile-recovery value from enabling pack recovery. - Add GitProcess.TryGetBoolFromConfig. GitRepo, CloneVerb, PrefetchVerb, BlobPrefetcher, and InProcessMount pass it as the reader. Read gvfs.mount-progress through the static helper. - In GVFS.Hooks, read gvfs.show-hydration-status with the parent Git executable, as the alias check does. Share the config query and retry code between the two reads. - Close the redirected standard input in ProcessHelper. With GIT_CONFIG=-, git reads config from standard input, and a hook query waited for input forever. - Add unit tests for the git route, the libgit2 route, an unset key, a failed git read through each path, a git reader that throws, the output parser, the git command lines, and the closed standard input. Assisted-by: Claude Opus 5.5 Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
Tyrie Vella (tyrielv)
force-pushed
the
tyrielv/libgit2-config-env-fallback
branch
from
November 12, 2026 18:39
b49332f to
d619851
Compare
Nathan Baird (ShiningMassXAcc)
requested changes
Nov 12, 2026
Nathan Baird (ShiningMassXAcc)
left a comment
Member
There was a problem hiding this comment.
Please add the end-to-end validation requested in the inline comment.
| IDictionary environment, | ||
| int configReadMaxAttempts = GitConfigReadRetry.MaxAttempts) | ||
| { | ||
| if (EnvironmentChangesGitConfig(environment)) |
There was a problem hiding this comment.
Please add an end-to-end test where an environment-supplied boolean disagrees with local gvfs.* config and assert actual GVFS behavior. For example, with a completed prefetch baseline, override gvfs.prefetch-offload in both directions and assert mount offload versus direct execution. The mock-based routing tests do not prove the compiled runtime path honors the effective value.
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.
Problem and Context
libgit2 does not read the config that
GIT_CONFIG_GLOBAL,GIT_CONFIG_SYSTEM,GIT_CONFIG_NOSYSTEM,GIT_CONFIG,GIT_CONFIG_COUNT, orGIT_CONFIG_PARAMETERSselect or supply.RetryConfigalready detects these variables withLibGit2Repo.EnvironmentChangesGitConfig()and reads its settings with git.exe. The booleangvfs.*settings did not. They read the user's real config and ignored the value from the environment.This affects
gvfs.trust-pack-indexes,gvfs.prefetch-offload,gvfs.prefetch-use-idx,gvfs.enable-packfile-recovery,gvfs.background-cache-auth,gvfs.mount-progress, andgvfs.show-hydration-status. Git setsGIT_CONFIG_PARAMETERSfor everygit -c <key>=<value>command, so the hooks see these variables often. For example,CloneNetworkTestssetsgvfs.trust-pack-indexesthroughGIT_CONFIG_GLOBAL. The clone ignores that value. The test passes only because its value matches the default.Changes
EnvironmentChangesGitConfig()is true, read boolean settings withgit config --type=bool. Git normalizes the value, exits with 1 when the key is unset, and fails when the value is not a boolean. When the environment does not change config, the reads still use libgit2.LibGit2Repo.TryReadConfigBoolWithGitdelegate. The staticLibGit2Repo.GetConfigBoolOrDefaultand everyLibGit2RepoInvokerconstructor require it. Remove the invoker constructors that took no reader.gvfs.enable-packfile-recoveryvalue stops maintenance instead of enabling pack recovery.GitProcess.TryGetBoolFromConfig.GitRepo,CloneVerb,PrefetchVerb,BlobPrefetcher, andInProcessMountpass it as the reader.GitReposupplies the reader thatPrefetchStep,PackfileMaintenanceStep, andGitStatusCacheuse.gvfs.mount-progressnow uses the static helper instead of its ownLibGit2Reporead.GVFS.Hooks, readgvfs.show-hydration-statuswith the parent Git executable, as the alias check does. The query setsCOMMAND_HOOK_LOCK, and it does not search the current directory orPATHforgit. The alias check and this read share the config query and retry code.ProcessHelper.Runchild. No caller writes to it. WithGIT_CONFIG=-, git reads config from standard input, and a hook query waited for input forever.LibGit2Repo, becauseGVFS.HookscompilesLibGit2Repo.csbut notGitProcess.cs.git configcommand lines inGitProcessand the hook, and the closed standard input inProcessHelper.Known gaps and deliberate decisions
GitProcess.GitProcessruns git fromEnvironment.SystemDirectory. Thus a relativeGIT_CONFIG_GLOBALorGIT_CONFIGpath resolves against that directory, and git reports the key as unset.RetryConfigand every otherGitProcessconfig read already behave this way. Deferred to a separate change.GitRepo.TryGetConfigValue(gvfs.max-active-enumerations),GetConfigString, andForEachMultiVarConfigstill ignore these environment variables. This change covers only boolean settings.gitandgvfsby name for the worktree and prefetch commands. Windows searches the current directory beforePATHfor those names. This change does not alter those launches.