cwd: git_root misses a worktree or submodule (.git file) when git cannot run

オープン
#586 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
git, lua, neovim

調査の方向性

Start with the fallback walk in lua/claudecode/cwd.lua and the existing no-git cases in tests/integration/cwd_path_characters_spec.lua. Add worktree and submodule cases created with real git, then look them up with git off PATH; update the README wording and clean up the specified tests/unit/cwd_spec.lua helpers. Run check.sh and --record; done when the no-git lookups return the worktree root and all checks pass.

索引モデルが issue の本文から書いたものです。

説明

needs-triage

cwd.git_root misses a git worktree or a submodule when git cannot run.

Defect. When git is missing from PATH or fails, the fallback walk in lua/claudecode/cwd.lua tests vim.fn.isdirectory(dir .. "/.git"). A worktree or a submodule has a .git file (gitdir: ...), so the walk skips it and returns nil, or a repository above it. With git, the answer is the worktree folder.

Reproduction (on main, Neovim 0.12.3 and 0.8.0):

git init main && git -C main commit --allow-empty -m i
git -C main worktree add ../wt && mkdir wt/sub

Run require("claudecode.cwd").git_root("<R>/wt") and git_root("<R>/wt/sub") once with git on PATH and once with PATH set to an empty folder (vim.o.shell = "/bin/sh"). With git: <R>/wt for both. Without git: nil for both.

Fix. In the walk, also accept vim.fn.filereadable(dir .. "/.git") == 1. Say "a .git folder or file" in lua/claudecode/README.md. Add worktree and submodule cases to the no-git mode of tests/integration/cwd_path_characters_spec.lua (create them with real git, look them up with git off PATH). cwd.lua is covered by verify-diff-lifecycle, so run the full check.sh and --record.

Test cleanup in the same PR (tests/unit/cwd_spec.lua):

  1. Lines 46 and 57 use assert(os.execute("mkdir -p ...")). That never fails under LuaJIT, because os.execute returns 0 or 256 and both are truthy (#570 fixed the same bug in two other files). Check status == 0 or status == true, and move #570's local shell helper to tests/helpers/.
  2. saved.finddir is saved (line 25) and restored (line 30), but nothing stubs finddir since #561. Delete both uses.

Related: the symlink walk issue filed next to this one touches the same walk; do both in one PR or this one first.

Owner: the next maintainer pass on cwd.lua. 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分
マージ済み PR(30日)
210

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

coder/claudecode.nvim のほかの issue

coder/claudecode.nvim の issue をすべて見る

似ている issue

Lua の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。