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 摘要。