Skip to content

Commit f81149a

Browse files
committed
fix: open selector when already in worktree instead of exiting
1 parent 966cc4d commit f81149a

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

bin/git-wt

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -199,22 +199,10 @@ REPO_NAME=$(basename "$GIT_ROOT")
199199
# Check if we're in a worktree (not the main checkout)
200200
GIT_DIR=$(git -C "$GIT_ROOT" rev-parse --git-dir)
201201
if [[ "$GIT_DIR" == *".git/worktrees/"* ]]; then
202-
# We're in a worktree - find the main checkout
202+
# We're in a worktree - find the main checkout and use that for operations
203203
MAIN_CHECKOUT=$(git -C "$GIT_ROOT" rev-parse --path-format=absolute --git-common-dir | sed 's|/.git$||')
204-
205-
if [[ -n "$TARGET_BRANCH" ]]; then
206-
# If branch specified, switch to it from main checkout
207-
echo "Currently in a worktree. Switching context to main checkout..."
208-
GIT_ROOT="$MAIN_CHECKOUT"
209-
else
210-
echo ""
211-
gum style --border rounded --padding "0 1" --border-foreground 214 \
212-
"Already in a worktree"
213-
echo ""
214-
echo "Main checkout: $MAIN_CHECKOUT"
215-
echo "Current worktree: $GIT_ROOT"
216-
exit 0
217-
fi
204+
GIT_ROOT="$MAIN_CHECKOUT"
205+
REPO_NAME=$(basename "$GIT_ROOT")
218206
fi
219207

220208
# Fetch from remote first

0 commit comments

Comments
 (0)