fix(shell): check git repo before running git commands to prevent TCC prompts (#1677)

Co-authored-by: BillionClaw <billionclaw@users.noreply.github.com>
This commit is contained in:
BillionToken 2026-03-20 15:13:58 +08:00 committed by GitHub
parent e0c301b277
commit af45c421e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View file

@ -451,6 +451,8 @@ _cmux_prompt_command() {
_CMUX_GIT_LAST_PWD="$pwd"
_CMUX_GIT_LAST_RUN=$now
{
# Skip git operations if not in a git repository to avoid TCC prompts
git rev-parse --git-dir >/dev/null 2>&1 || return 0
local branch dirty_opt=""
branch=$(git branch --show-current 2>/dev/null)
if [[ -n "$branch" ]]; then

View file

@ -236,6 +236,9 @@ _cmux_report_git_branch_for_path() {
[[ -n "$CMUX_TAB_ID" ]] || return 0
[[ -n "$CMUX_PANEL_ID" ]] || return 0
# Skip git operations if not in a git repository to avoid TCC prompts
git -C "$repo_path" rev-parse --git-dir >/dev/null 2>&1 || return 0
local branch dirty_opt="" first
branch="$(git -C "$repo_path" branch --show-current 2>/dev/null)"
if [[ -n "$branch" ]]; then