fix worktree mounts using primary enlistment's .gvfs paths#1998
Open
tyrielv wants to merge 1 commit into
Open
Conversation
51724bd to
a9d689d
Compare
Worktree mounts shared the primary enlistment's .gvfs metadata (placeholder database, RepoMetadata, diagnostics, corrupt objects) instead of using their own per-worktree .gvfs directory. This caused stale file content after git reset --hard in worktrees, because placeholder tracking was shared with the primary mount. Root cause: code throughout the codebase derived .gvfs paths from EnlistmentRoot, which always resolves to the primary enlistment root even for worktree mounts. The correct property is DotGVFSRoot, which resolves to the per-worktree .gvfs for worktree mounts and the primary .gvfs for primary mounts. Product fixes: - GVFSDatabase: accept dotGVFSRoot directly instead of deriving from EnlistmentRoot; update InProcessMount, SparseVerb, DiskLayoutUpgrade, EnlistmentPathData, ProfilingEnvironment call sites - GitRepo: resolve DotGVFSRoot at construction for corrupt object paths - GVFSVerb.InitializeLocalCacheAndObjectsPaths: use DotGVFSRoot for RepoMetadata (affects dehydrate, prefetch) - DiagnoseVerb: use DotGVFSRoot for .gvfs file collection and RepoMetadata initialization - CacheVerb: use DotGVFSRoot for RepoMetadata - RequiredGitConfig: narrow parameter to GVFSEnlistment, use DotGVFSRoot - GVFSLogsRoot: derive from DotGVFSRoot instead of re-deriving - GitMaintenanceStep: check WorkingDirectoryRoot for existence - HooksInstaller: use WorkingDirectoryRoot in error messages Rename to prevent recurrence: - Rename Enlistment.EnlistmentRoot to PrimaryEnlistmentRoot, forcing every caller to explicitly choose the right path property. Audit of all ~280 references across ~75 files confirmed each usage is correct. Test: - Add WorktreeUsesPerWorktreePlaceholderDatabase functional test Assisted-by: Claude Opus 4.6 Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
a9d689d to
656e3a1
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
Worktree mounts shared the primary enlistment's
.gvfsmetadata (placeholder database, RepoMetadata, diagnostics, corrupt objects) instead of using their own per-worktree.gvfsdirectory.Symptoms: after
git reset --hardin a worktree, fully-materialized files retained stale content because placeholder tracking was shared with the primary mount. The skip-worktree bit hid the stale content fromgit status/git diff.Root cause: code throughout the codebase derived
.gvfspaths fromEnlistmentRoot, which always resolves to the primary enlistment root -- even for worktree mounts. The correct property isDotGVFSRoot, which resolves to the per-worktree.gvfsfor worktree mounts.Fix
Product fixes
dotGVFSRootdirectly instead of deriving fromEnlistmentRoot; update all call sitesDotGVFSRootat construction for corrupt object pathsDotGVFSRootfor RepoMetadata (affects dehydrate, prefetch)DotGVFSRootfor .gvfs file collection and RepoMetadataDotGVFSRootfor RepoMetadataGVFSEnlistment, useDotGVFSRootDotGVFSRootinstead of re-derivingWorkingDirectoryRootfor existenceWorkingDirectoryRootin error messagesRename to prevent recurrence
Rename
Enlistment.EnlistmentRoottoPrimaryEnlistmentRoot, forcing every caller to explicitly choose the right path property. Audit of all ~280 references across ~75 files confirmed each usage is correct.Test
Added
WorktreeUsesPerWorktreePlaceholderDatabasefunctional test: creates a worktree outside the enlistment tree, materializes a file, and verifies the per-worktreeVFSForGit.sqlitecontains placeholder entries.Validation