chore: track origin EE branch in worktree setup when absent locally (#9504)

* chore: track origin EE branch in worktree setup when absent locally

* chore: pass --track to worktree add so upstream is set regardless of git config

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* chore: guard first worktree arm on local branch to avoid remote-only DWIM

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
hugocasa
2026-08-06 10:13:16 +02:00
committed by GitHub
parent c03bd34be9
commit c8ba771797
+8 -2
View File
@@ -181,8 +181,14 @@ wm_setup_ee_worktree() {
mkdir -p "$(dirname "$ee_worktree_dir")"
git -C "$ee_repo" fetch --quiet 2>/dev/null || true
if git -C "$ee_repo" worktree add "$ee_worktree_dir" "$branch" 2>/dev/null; then
echo "Created EE worktree at $ee_worktree_dir (branch: $branch)"
# Guard on refs/heads: without it, `worktree add` DWIMs a remote-only branch
# into a new local branch here, skipping the explicit --track arm below.
if git -C "$ee_repo" show-ref --verify --quiet "refs/heads/$branch" \
&& git -C "$ee_repo" worktree add "$ee_worktree_dir" "$branch" 2>/dev/null; then
echo "Created EE worktree at $ee_worktree_dir (existing local branch: $branch)"
elif git -C "$ee_repo" show-ref --verify --quiet "refs/remotes/origin/$branch" \
&& git -C "$ee_repo" worktree add --track -b "$branch" "$ee_worktree_dir" "origin/$branch" 2>/dev/null; then
echo "Created EE worktree at $ee_worktree_dir (tracking origin/$branch)"
elif git -C "$ee_repo" worktree add -b "$branch" "$ee_worktree_dir" main 2>/dev/null; then
echo "Created EE worktree at $ee_worktree_dir (new branch: $branch from main)"
else