git_add reports 'Files staged successfully' when nothing was staged
まだ誰も着手していません。
評価
調査の方向性
src/git/src/mcp_server_git/server.py:132-153 から始め、既存の git_add テストを確認してください。これらは現在、実際の変更をステージングするケースをカバーしています。空のリストとクリーンなツリーのケースを再現し、報告された結果がインデックスと一致すること、および空のファイルリストが仕様どおりに処理されることを示すカバレッジを追加してください。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 90.5k
- フォーク
- 11.7k
- 平均マージ
- 2日 2時間
- マージ済み PR(30日)
- 5
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/servers のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
modelcontextprotocol/servers#4830 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
modelcontextprotocol/servers#4829 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
modelcontextprotocol/servers#4812 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
modelcontextprotocol/servers#4804 · コメント 1 件 ·
-
README gate confirmation command can be used by any commenter, bypassing the "readme: pending" gate オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
modelcontextprotocol/servers#4796 ·
modelcontextprotocol/servers の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
calcite-components needs triage refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Esri/calcite-design-system#15203 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
danielmiessler/LifeOS#2218 ·