Skip to content

Reduce redundant Git and worktree lookups - #579

Merged
skarim merged 2 commits into
skarim/test-improvementsfrom
skarim/worktree-probe-optimizations
Oct 22, 2026
Merged

skarim merged 2 commits into
skarim/test-improvementsfrom
skarim/worktree-probe-optimizations

Conversation

@skarim

@skarim skarim commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Optimizes GitOps and worktree operations by reducing repeated lookups, and updates the regression tests to preserve existing safety checks.

Functionality and impact

  • Reuses directory paths from the current validation instead of querying Git again.
  • Reuses the current preflight executor instead of resolving the same worktree twice.
  • Preserves identity, ownership, and recovery checks without adding a persistent cache.

Key areas to review

@skarim
skarim added this pull request to stack #580 October 22, 2026 02:28
@skarim skarim changed the title Reuse validated worktree metadata within operations Reuse worktree validation within scoped operations Oct 22, 2026
@skarim
skarim force-pushed the skarim/worktree-probe-optimizations branch from c762657 to 0eea91b Compare October 22, 2026 05:15
@skarim
skarim marked this pull request as ready for review October 22, 2026 14:30
Copilot AI balanced review requested due to automatic review settings October 22, 2026 14:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The narrowly scoped refactor preserves existing safety checks, adds focused regression coverage, and has no identified blocking issues.

No open issues 🎉

What changed in this PR

This PR reduces repeated Git lookups in scoped worktree operations while preserving per-call validation and avoiding persistent caching.

Changes:

  • Reuses directory paths obtained during the current identity validation.
  • Reuses the preflight executor when preparing a branch.
  • Adds regression tests for lookup counts, per-call freshness, and cleanliness checks.
File Description
internal/​worktree/​context.go Extracts shared preflight logic and reuses its executor in Prepare.
internal/​worktree/​context_test.go Tests executor reuse and cleanliness checks within each call.
internal/​git/​worktree.go Reuses validated directory metadata for lookups and worktree selection.
internal/​git/​gitops.go Routes GitDir through the validated directory helper.
internal/​git/​gitops_test.go Tests reduced directory probes and revalidation after a worktree moves.

Review effort: Balanced

@skarim skarim changed the title Reuse worktree validation within scoped operations Reduce redundant Git and worktree lookups Oct 22, 2026
Comment thread internal/git/gitops_test.go

@francisfuzz francisfuzz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 , left one non-blocking comment

@skarim
skarim merged commit 6721eba into main Oct 22, 2026
15 checks passed
@skarim
skarim deleted the skarim/worktree-probe-optimizations branch October 22, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants