git_add reports 'Files staged successfully' when nothing was staged
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 74/100
Direzione di ricerca
Inizia da src/git/src/mcp_server_git/server.py:132-153 ed esamina i test git_add esistenti, che attualmente coprono lo staging di una modifica reale. Riproduci i casi di lista vuota e albero pulito, quindi aggiungi test che dimostrino che il risultato riportato corrisponde all’indice e che una lista di file vuota viene gestita come specificato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
git_add returns the constant string Files staged successfully regardless of what the index actually took.
src/git/src/mcp_server_git/server.py:132-153:
def git_add(repo: git.Repo, files: list[str]) -> str:
if files == ["."]:
repo.git.add(".")
else:
...
repo.git.add("--", *files)
return "Files staged successfully"
git add exits 0 when it stages nothing, so two calls report success having done nothing:
files: []runsgit add --with no pathspec, which is a no-op. The schema puts no minimum on the list.files: ["."]on a tree with no changes stages nothing.
A nonexistent path is not affected — git add -- nope.txt already fails with "pathspec did not match any files".
The practical failure: an agent computes a file list that comes back empty — a filter, a glob, a diff parse that matched nothing — and passes it. It is told the files are staged. Paired with #4762, it can then stage nothing, commit nothing, and report the work as committed.
To Reproduce
import git
repo = git.Repo(".") # a tracked file, edited but not staged
repo.git.add("--") # files: []
repo.git.diff("--cached", "--name-only") # '' — nothing staged
# git_add returns: "Files staged successfully"
Same on a clean tree with files: ["."]:
tree clean? True
git_add(["."]) -> "Files staged successfully"
actually staged: ''
Expected behavior
An empty files list should be rejected, since it can never stage anything. Otherwise the reported outcome should reflect what the index actually holds, rather than the exit status.
Additional context
No test covers either case; the existing git_add tests all stage a real change first.
- Lingua principale
- TypeScript
- Stelle
- 90.5k
- Fork
- 11.7k
- Merge medio
- 2g 2h
- PR unite (30g)
- 5
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modelcontextprotocol/servers
-
Docs: `fetch` installs npm packages during a tool call, which is worth stating for deployments Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
modelcontextprotocol/servers#4830 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
modelcontextprotocol/servers#4829 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
modelcontextprotocol/servers#4812 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
modelcontextprotocol/servers#4804 · 1 commento ·
-
README gate confirmation command can be used by any commenter, bypassing the "readme: pending" gate Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
modelcontextprotocol/servers#4796 ·
Tutte le issue di modelcontextprotocol/servers
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
[Bug]: Matrix progress drafts fail with "Matrix runtime not initialized" during tool activity Apertabug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
calcite-components needs triage refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Esri/calcite-design-system#15203 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
danielmiessler/LifeOS#2218 ·