From fdf63e3fc89ab25a0a3ae5f7708f26a9b1a08187 Mon Sep 17 00:00:00 2001 From: weichen Date: Wed, 30 Sep 2026 03:37:01 +0000 Subject: [PATCH] Fall back to prune-based removal for submodule-bearing worktrees Why: git unconditionally refuses worktree remove when the tree contains gitlinks (index-level check; deinit does not bypass it), so the PR#4 fix path still failed on the second real task. Evidence: after deinit the worktree was clean and submodule dirs empty, yet remove refused; rm -rf + worktree prune is the documented workaround and was proven manually on the empty-list task worktree. Impact: task-finish now completes the recycle path automatically after its merge verification; no guard weakened. Refs: Agent-System-Dev PR#4; policy/tool-adaptation-matrix.md A5 --- scripts/task.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/task.sh b/scripts/task.sh index 6d4b3473..788335f7 100755 --- a/scripts/task.sh +++ b/scripts/task.sh @@ -127,7 +127,9 @@ cmd_finish() { echo "[verified] ${branch} 已包含于 origin/${TARGET_BRANCH};成果已落盘" fi git submodule deinit --all -f >/dev/null 2>&1 || true - git -C "$mainrepo" worktree remove "$PWD" 2>/dev/null || { echo "finish: worktree remove 失败(含未清理内容)——已验证合入,可手动 rm -rf 后 git worktree prune" >&2; exit 1; } + # git 对含 gitlink 的 worktree 无条件拒绝 remove(查索引,与 deinit 无关): + # 已验证合入且子模块已 deinit 后,直接清目录并 prune。 + git -C "$mainrepo" worktree remove "$PWD" 2>/dev/null || { rm -rf "$PWD"; git -C "$mainrepo" worktree prune; } git -C "$mainrepo" branch -d "$branch" 2>/dev/null || git -C "$mainrepo" branch -D "$branch" git -C "$mainrepo" worktree prune git push -q --delete origin "$branch" 2>/dev/null || true