Skip to content

Conversation

@adm-robinweston
Copy link
Contributor

@adm-robinweston adm-robinweston commented Jan 23, 2026

This PR fixes an issue where the base directory itself could appear in the worktree list output when it matched the prefix pattern.

This results in gtr list showing it as a detached worktree.

Changes

  • Added check to skip the base directory itself in the cmd_list() function
  • Prevents the base directory from being included in both sorted and unsorted list outputs

Testing

  • Verified that only actual worktree directories are shown in the list output

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where the root worktrees directory could appear in git gtr listings; listings and porcelain outputs now omit the base directory when not a matching subtree.

✏️ Tip: You can customize this high-level summary in your review settings.

Prevent the base directory itself from appearing in the list output
when it matches the prefix pattern. This ensures only actual worktree
directories are shown.
@coderabbitai
Copy link

coderabbitai bot commented Jan 23, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

Added guard checks in git worktree listing logic to skip the base worktrees directory when iterating entries, preventing the root worktrees directory from being included in porcelain and list outputs when the name prefix is empty. Minor inline comments added.

Changes

Cohort / File(s) Summary
Git Worktree Base Directory Exclusion
bin/gtr
Added guard conditions in both porcelain and non-porcelain listing paths to continue when the iterated directory equals base_dir, preventing the root worktrees directory from appearing in results. Small inline comments added.

Sequence Diagram(s)

(omitted — change is a small guard in a single script; no multi-component sequential flow to visualize)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • NatoBoram

Poem

🐰 A tiny guard hops in place,
Skipping roots with gentle grace,
No more base where lists collide,
Only branches now reside,
Hooray — tidy worktree space! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: excluding the base directory from worktree list output, which directly matches the primary change in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@helizaga helizaga merged commit d6e2e67 into coderabbitai:main Jan 24, 2026
1 check was pending
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