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

Abierto
#586 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
58/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
git, lua, neovim

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Lua
Estrellas
3.2k
Forks
223
Merge medio
6 h 7 min
PR fusionados (30 d)
210

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

  • Sin Dockerfile ni archivo de Docker Compose
  • Sin plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de coder/claudecode.nvim

Todos los issues de coder/claudecode.nvim

Issues similares

Más issues de Lua

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.