Skip to content

feat: add git worktree discovery support - #42

Merged
josephschmitt merged 5 commits into
mainfrom
claude/add-worktree-support-HDICw
Mar 13, 2026
Merged

feat: add git worktree discovery support#42
josephschmitt merged 5 commits into
mainfrom
claude/add-worktree-support-HDICw

Conversation

@josephschmitt

@josephschmitt josephschmitt commented Mar 13, 2026

Copy link
Copy Markdown
Owner

Add --worktrees and --no-worktrees flags for controlling git worktree
discovery behavior:

  • Default (no flags): worktrees found during normal walk are tagged with
    IsWorktree metadata but otherwise included as usual
  • --worktrees: actively discovers worktrees from parent repos'
    .git/worktrees/ directory, even if they live outside search paths
  • --no-worktrees: filters out any worktree projects from results

Detection works via two paths:

  • Path A: detects .git files (vs directories) during walk, parses gitdir
    reference to identify worktree parent
  • Path B: reads .git/worktrees/ entries from parent repos to discover
    linked worktrees outside search paths

Worktree metadata is exposed in JSON output (isWorktree, worktreeParent),
format strings (%w for parent path), and display labels show (worktree)
suffix. Cache keys include worktree flags to prevent stale results.

https://claude.ai/code/session_01136P3sSGSiRns9QuTMRF1q

Add --worktrees and --no-worktrees flags for controlling git worktree
discovery behavior:

- Default (no flags): worktrees found during normal walk are tagged with
  IsWorktree metadata but otherwise included as usual
- --worktrees: actively discovers worktrees from parent repos'
  .git/worktrees/ directory, even if they live outside search paths
- --no-worktrees: filters out any worktree projects from results

Detection works via two paths:
- Path A: detects .git files (vs directories) during walk, parses gitdir
  reference to identify worktree parent
- Path B: reads .git/worktrees/ entries from parent repos to discover
  linked worktrees outside search paths

Worktree metadata is exposed in JSON output (isWorktree, worktreeParent),
format strings (%w for parent path), and display labels show "(worktree)"
suffix. Cache keys include worktree flags to prevent stale results.

https://claude.ai/code/session_01136P3sSGSiRns9QuTMRF1q

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

claude and others added 4 commits March 13, 2026 20:47
- Add errcheck nolint directive for read-only file close
- Use tagged switch instead of if-else chain per staticcheck QF1003

https://claude.ai/code/session_01136P3sSGSiRns9QuTMRF1q
Refactor walkPath to use the shared findBestMarker method instead of
duplicating marker-checking logic inline. Remove redundant hardcoded
"/.git" suffix check in discoverWorktrees since os.PathSeparator
already covers it. Revert unrelated alignment changes to NoIgnore and
NoNested fields in CLI struct.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add worktree feature to README: Features list, CLI Flags table, Format
Placeholders table, and a dedicated Git Worktree Support section with
usage examples and config options. Update CLAUDE.md architecture section
with worktree detection design pattern.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@josephschmitt
josephschmitt merged commit 1642b5b into main Mar 13, 2026
5 checks passed
@josephschmitt
josephschmitt deleted the claude/add-worktree-support-HDICw branch March 13, 2026 22:02
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.

2 participants