Repository navigation
Preserve GVFS locks when commands collide with aliases - #2139
Draft
Tyrie Vella (tyrielv) wants to merge 3 commits into
Draft
Tyrie Vella (tyrielv) wants to merge 3 commits into
Tyrie Vella (tyrielv) wants to merge 3 commits into
Conversation
Tyrie Vella (tyrielv)
force-pushed
the
tyrielv/alias-resolution
branch
from
October 21, 2026 17:52
be94aa3 to
e018f6a
Compare
1 of 3 tasks
Use one bounded retry policy for git.exe and libgit2 config reads. Retry only transient file access failures and preserve existing missing-key behavior. Retry the libgit2 repository open, which parses .git\config. Retry the git config alias lookup in the hooks. Let latency-sensitive hook callers use a smaller attempt budget. Match a transient failure only on the reason after the last "': " in an error line. A path or key that contains "Permission denied" no longer matches. Trace when a transient failure persists after all attempts. Do not trace config names that contain URL credentials. Add Enlistment.CreateGitProcess(ITracer). Use it for the mount cache server, retry, status cache, and required-config readers, so retries reach the mount trace. Assisted-by: GPT-5.6 Sol Assisted-by: Claude Sonnet 5.5 Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
RetryConfig started git.exe once for gvfs.max-retries and once for gvfs.timeout-seconds. Read both settings in process with libgit2. Open a transient repository without its object store when the working directory exists. Otherwise, read the global, XDG, system, and ProgramData config, as GitProcess.GetFromConfig does before clone creates the repository. The reads use the GitConfigReadRetry policy. libgit2 does not read GIT_CONFIG_PARAMETERS, GIT_CONFIG_COUNT, GIT_CONFIG_GLOBAL, GIT_CONFIG_SYSTEM, GIT_CONFIG_NOSYSTEM, or GIT_CONFIG. It also does not use GIT_DIR, which git.exe uses to select a repository when no working directory exists. When the environment sets any of these variables, read the settings with git.exe. libgit2 evaluates only the gitdir, gitdir/i, and onbranch includeIf conditions. It skips other conditions, such as hasconfig:remote.*.url, without an error. When the config has such a condition, the libgit2 read fails, and git.exe reads the setting. When libgit2 cannot read a setting for another reason, for example because it rejects the repository's ownership, read the setting with git.exe and trace RetryConfig_ReadWithGit. After a transient file access failure, do not read again with git.exe, because libgit2 already used the retry budget. Move integer setting parsing to GitConfigHelper, so both readers report the same default, minimum, and parse errors. When the LibGit2Repo constructor fails, it releases its libgit2 reference. Suppress finalization in that case, so the finalizer does not release the reference a second time. Assisted-by: Claude Opus 5.5 Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
Distinguish built-in hooks from external attempts before alias detection. Keep required locks when a real command takes precedence over an alias. Use the parent Git executable for config queries and suppress recursive hooks. Resolve external names on the inherited Windows PATH without command enumeration. Release external-command locks by typed ownership during post-command. Do not repeat mutable command resolution when deciding whether to release. Report alias-resolution failures and retain the conservative lock. Cover built-in and external collisions, genuine aliases, command spellings, config or executable-lookup failures, and lock-ownership responses. Keep lock-holder lifetimes deterministic in the functional cases. Exercise both hooks with a live Git PID and remove the external between calls. Keep the existing lock exemption policy unchanged. Assisted-by: GPT-6.1 Sol Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
Tyrie Vella (tyrielv)
force-pushed
the
tyrielv/alias-resolution
branch
from
October 21, 2026 21:14
e018f6a to
c45955e
Compare
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
The command hook uses a static command inventory before it checks for aliases.
The inventory omits built-ins such as
stashand cannot cover custom executables.A same-name alias can therefore bypass the required lock even when Git runs the real command.
Nested Git processes from external commands inherit hook suppression, so they cannot supply the missing lock.
Ordinary
git stashalready takes the lock.This repair addresses command-resolution collisions, not general stash reliability or the read-only lock exemption policy.
Changes
Related: #2138 changes read-only lock exemptions.
This repair remains separate and does not depend on that policy change.
Known gaps and deliberate decisions