Repository navigation
Read gvfs.* booleans with git when the environment changes config - #2156
Closed
Tyrie Vella (tyrielv) wants to merge 1 commit into
Closed
Tyrie Vella (tyrielv) wants to merge 1 commit into
Tyrie Vella (tyrielv) wants to merge 1 commit into
Conversation
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 and make the static LibGit2Repo.GetConfigBoolOrDefault require it. Parse the git output in LibGit2Repo so that GVFS.Hooks, which compiles LibGit2Repo.cs without GitProcess, can share the parser. - Add GitProcess.TryGetBoolFromConfig. - Give LibGit2RepoInvoker an optional git reader. GitRepo supplies one from its enlistment. - Pass a git reader from CloneVerb, PrefetchVerb, InProcessMount, and GVFS.Hooks. Read gvfs.mount-progress through the static helper. - Add unit tests for the git route, the libgit2 route, an unset key, a failed git read, the output parser, and the git command line. Assisted-by: Claude Opus 5.5 Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
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.background-cache-auth,gvfs.mount-progress, andgvfs.show-hydration-status. 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. A failed read logs a warning and uses the default, as the libgit2 read does.LibGit2Repo.TryReadConfigBoolWithGitdelegate. The staticLibGit2Repo.GetConfigBoolOrDefaultnow requires it, so a new caller cannot skip the git route.LibGit2Repo.GVFS.HookscompilesLibGit2Repo.cswithoutGitProcess, so the hook and the other processes share one parser.GitProcess.TryGetBoolFromConfig.LibGit2RepoInvokeran optional git reader.GitReposupplies one from its enlistment. This coversPrefetchStep,PackfileMaintenanceStep, andGitStatusCache.CloneVerb,PrefetchVerb,InProcessMount, andGVFS.Hooks. The hook runsgitfromPATHin the current directory, as its alias check already does.gvfs.mount-progressnow uses the static helper instead of its ownLibGit2Reporead.git config --type=boolcommand line.