fix(worktree): make add's base-ref fetch non-interactive and resilient#36
Merged
Merged
Conversation
The `worktree:add` task fetched the base ref with a plain `git fetch`, which — when the task runs from a non-interactive context and SSH_AUTH_SOCK is stale — can fall into a credential/passphrase prompt. Without a terminal that surfaces as an intermittent "no terminal" style failure, and because of `set -euo pipefail` the task aborts before `git worktree add`, leaving no worktree. Force the fetch to be strictly non-interactive (GIT_TERMINAL_PROMPT=0, SSH BatchMode, ConnectTimeout) so git can never prompt, and fall back to the last-known local base ref with a warning instead of aborting when the remote is unreachable. Only error out when no local base ref exists. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
nolte
marked this pull request as ready for review
July 14, 2026 12:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Harden the
worktree:addtask so its base-ref fetch can never trigger acredential/passphrase prompt. Previously, running the task from a non-interactive
context with a stale
SSH_AUTH_SOCKcould surface an intermittent "no terminal"failure and abort before the worktree was created.
Changes
GIT_TERMINAL_PROMPT=0plus SSH
BatchMode=yesandConnectTimeout=10, so git can never fall into aterminal prompt.
when the remote is unreachable, so a worktree is still created.
SSH_AUTH_SOCK) only when nolocal base ref exists to fall back to.
Linked issues
None
Testing
task worktree:add -- chore/verify-fix verify-fix < /dev/null— worktree created, exit 0.worktree:addruns — both exit 0, no git-lock race.task --yes lint— all pre-commit hooks pass.Risk / rollout notes
Low risk. Behavior change is limited to the fetch step of
worktree:add: it nowdegrades to the local base ref on an unreachable remote instead of failing. No
consumer-facing var or task signature changes.