anomalyco / anomalyco/opencode
git worktree remove: forceRequired is false on non-English locales
@nexxeln is already working on this.
Since Aug 5, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Git.worktree.remove decides whether --force is required by matching git's stderr against English text (packages/core/src/git.ts):
forceRequired: operation === "remove" && /contains modified or untracked files|is dirty/i.test(message),
git localizes its diagnostics, so this only matches on an English system. With LANG=zh_CN.UTF-8 the same failure reads:
致命错误:'../wt' 包含修改或未跟踪的文件,使用 --force 删除
The regex misses, forceRequired becomes false, and callers lose the signal that retrying with --force would succeed. The user sees a bare failure instead of the hint.
git worktree remove has no --porcelain or other machine-readable output, so there is nothing structured to parse instead.
This also makes ProjectCopy > requires force to remove a dirty git worktree fail on any non-English machine, while passing on CI because runners default to an English locale.
Steps to reproduce
mkdir -p /tmp/wt && cd /tmp/wt && git init -q main && cd main
git -c user.email=a@b -c user.name=a commit -q --allow-empty -m init
git worktree add -q ../wt && echo dirty > ../wt/dirty.txt
LC_ALL=C git worktree remove ../wt # English: "contains modified or untracked files"
LC_ALL=zh_CN.UTF-8 git worktree remove ../wt # localized, regex no longer matches
Or from the repo, on a non-English system:
cd packages/core && bun test test/project-copy.test.ts
requires force to remove a dirty git worktree fails on expect(error.forceRequired).toBe(true).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.