cwd: git_root follows a symlink by name when git cannot run

未关闭 适合新手
#587 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
lua
领域
backend

调研方向

阅读 lua/claudecode/cwd.lua 和 tests/integration/cwd_path_characters_spec.lua 中的无 Git 模式。先检查回退遍历和 simplify() 如何处理符号链接,然后在两侧使用 realpath 将结果与真实 Git 进行比较。当 Git 不可用时,link 和 link/.. 案例与 Git 结果一致即可完成;issue 还要求为 verify-diff-lifecycle 提供 check.sh 和 --record。

由索引模型根据 Issue 内容生成。

描述

needs-triage

cwd.git_root follows a symbolic link by its name when git cannot run, so it answers with the wrong repository.

Defect. The fallback walk in lua/claudecode/cwd.lua is lexical. For a start folder that is a link into another repository, it tests the link's own folder, then the folders above the link's name. It answers the repository of the link's parent, where git answers the repository of the link target. A .. after a link (X/lnk/..) is also resolved by name by simplify(), while git resolves it through the target.

Reproduction (on main, Neovim 0.12.3 and 0.8.0):

git init r1 && git init r2 && mkdir -p r1/sub r2/deep
ln -s "$PWD/r2/deep" r1/sub/lnk

require("claudecode.cwd").git_root("<R>/r1/sub/lnk") gives <R>/r2 with git and <R>/r1 with git off PATH.

Fix. Start the walk from vim.loop.fs_realpath(start_dir) (available in Neovim 0.8) and fall back to the lexical path when it returns nil. The answer is then the physical repository path, as git rev-parse --show-toplevel returns it. Add a link case and a link/.. case to the no-git mode of tests/integration/cwd_path_characters_spec.lua, compared against real git with realpath on both sides (macOS has /tmp as a link). Full check.sh and --record for verify-diff-lifecycle.

Owner: the next maintainer pass on cwd.lua, together with the worktree issue. Deferred from the README verification run with the maintainer's agreement.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

主要语言
Lua
星标
3.2k
派生
223
平均合并
6 小时 7 分钟
30 天内合并 PR
210

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

coder/claudecode.nvim 的其他 Issue

查看 coder/claudecode.nvim 的全部 Issue

相似的 Issue

更多 Lua Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。