Skip to content

Improve performance when opening repositories with worktrees #4929

@eamodio

Description

@eamodio

Summary

Improves performance when opening repositories that have multiple worktrees by intelligently sharing Git data across worktrees.

Impact

  • Shares cached Git data (tags, remotes, stashes, contributors) across worktrees of the same repository, eliminating redundant Git operations
  • Pre-populates branch cache from branch list to avoid redundant rev-parse operations
  • Correctly handles worktree-specific state (like "current" branch flag) while sharing underlying data
  • Consolidates caches into a single structure with improved invalidation logic
  • Improves worktree naming for detached states by including folder context
  • Excludes worktrees from certain repository pickers where inappropriate

Validation

  • Test with multiple worktrees from the same repository
  • Verify branch detection shows correct current branch per worktree
  • Check that tag/remote/stash data is consistent across worktrees
  • Confirm cache invalidation propagates correctly

Risk

Medium - Core caching infrastructure changes. Unit tests added for cache behavior.

Metadata

Metadata

Assignees

Labels

area-gitIssues or features related to using Gitarea-worktreesIssues or features related to worktreesverified ✔Verified

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions