git_commit during a merge records one parent and leaves MERGE_HEAD in place
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
该 bug 位于 src/git/src/mcp_server_git/server.py,原因是 git_commit 调用 repo.index.commit() 时未处理合并状态。首先检查该函数以及 GitPython 的 IndexFile.commit() 方法签名。当 MERGE_HEAD 存在时,读取其对应的提交并作为 parent_commits 传入,随后清除 MERGE_HEAD、MERGE_MSG 和 MERGE_MODE。在 git 测试套件中添加一个测试:执行带 --no-commit 参数的合并操作,调用 git_commit,并断言存在两个父提交且无剩余合并状态。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
git_commit cannot conclude a merge. While a merge is in progress (MERGE_HEAD present, e.g. after git merge --no-commit or a resolved conflict), it writes a commit with one parent, HEAD, and leaves MERGE_HEAD (and MERGE_MSG) in place, so the repository stays in merge state and the merged branch's history is not recorded.
src/git/src/mcp_server_git/server.py, git_commit calls repo.index.commit(message). GitPython's IndexFile.commit() takes parent_commits=None, which means [repo.head.commit] only; it neither reads nor clears MERGE_HEAD.
Found in the Copilot review of #5007 (the fix for #4762), which keeps the empty-merge-commit case committable but, like the code before it, records it with one parent. This predates #5007: any merge resolved through git_commit has always been recorded this way.
To Reproduce
import git
# repo on main with a branch `side` that adds side.txt
repo.git.merge("side", "--no-commit", "--no-ff")
commit = repo.index.commit("merge side") # what git_commit does
len(commit.parents) # 1, git commit would give 2
(Path(repo.git_dir) / "MERGE_HEAD").exists() # True, merge still in progress
Expected behavior
While MERGE_HEAD is present, git_commit records HEAD plus every MERGE_HEAD commit as parents and clears the merge state, as git commit does (either by shelling out to git commit, or by passing parent_commits and removing MERGE_HEAD/MERGE_MSG/MERGE_MODE). A test asserts both parents and that MERGE_HEAD is gone.
Additional context
Related: #659 (a git_merge tool), which would make this path reachable from the server alone.
- 主要语言
- TypeScript
- 星标
- 91k
- 派生
- 11.8k
- 平均合并
- 6 小时 33 分钟
- 30 天内合并 PR
- 79
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/servers 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
modelcontextprotocol/servers#5071 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
modelcontextprotocol/servers#5059 · 1 条评论 ·
维护者通常 1 天内回复
-
mcp-server-fetch: `fetch` prompt returns JSON-RPC error code 0 with the raw exception text for an invalid URL可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
modelcontextprotocol/servers#4914 ·
维护者通常 1 天内回复
-
CLAUDE.md: tool-naming rule (kebab-case) disagrees with filesystem and memory servers可能已有人在做 @liang0417 于 9 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 92/100
modelcontextprotocol/servers#4892 · 1 条评论 ·
维护者通常 1 天内回复
-
Filesystem README recommends deprecated MCP Roots protocol for restricting directory access可能已有人在做 @its-amann 于 14 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
modelcontextprotocol/servers#4844 ·
维护者通常 1 天内回复
查看 modelcontextprotocol/servers 的全部 Issue
相似的 Issue
-
component:sight
难度 2/5 1-3 小时 新手友好度 78/100
agentic-os-org/ANOLISA#6738 · 2 条评论 ·
维护者通常 1 天内回复
-
bug Durable Agents Observability (AI Telemetry) status: needs triage
难度 2/5 1-3 小时 新手友好度 82/100
mastra-ai/mastra#26470 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
paperclipai/paperclip#15630 ·
维护者通常 1 天内回复
-
[good first issue, hacktoberfest] ⛩️ Add new Theme: Sakura Latte (good-first-issue)可能已有人在做 @PGrayCS 今天认领。 未关闭community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
难度 1/5 1-3 小时 新手友好度 78/100
lingdojo/kana-dojo#31937 · 1 条评论 · 5 个 reaction ·
维护者通常 1 天内回复
-
feature/cohorts feature/feature-flags team/feature-flags
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复