Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bin/gtr
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,10 @@ cmd_list() {

if [ -d "$base_dir" ]; then
# Find all worktree directories and output: path<tab>branch<tab>status
# Exclude the base directory itself to avoid matching when prefix is empty
find "$base_dir" -maxdepth 1 -type d -name "${prefix}*" 2>/dev/null | while IFS= read -r dir; do
# Skip the base directory itself
[ "$dir" = "$base_dir" ] && continue
local branch status
branch=$(current_branch "$dir")
[ -z "$branch" ] && branch="(detached)"
Expand Down Expand Up @@ -889,6 +892,8 @@ cmd_list() {
# Show worktrees sorted by branch name
if [ -d "$base_dir" ]; then
find "$base_dir" -maxdepth 1 -type d -name "${prefix}*" 2>/dev/null | while IFS= read -r dir; do
# Skip the base directory itself
[ "$dir" = "$base_dir" ] && continue
local branch
branch=$(current_branch "$dir")
[ -z "$branch" ] && branch="(detached)"
Expand Down